theouche merge ok

This commit is contained in:
CHIBOUB Chakib
2024-07-31 17:53:40 +02:00
8 changed files with 89 additions and 13 deletions

View File

@@ -204,12 +204,14 @@ document.addEventListener('DOMContentLoaded', () => {
function handleKeyDown(event) {
if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
console.log('Key press: ', event.key);
sendKeyPress(event.key.toLowerCase());
}
}
function sendKeyPress(key) {
if (socket.readyState === WebSocket.OPEN) {
console.log('Key sent: ', key);
socket.send(JSON.stringify({ type: 'key_press', key }));
}
}