diff --git a/client/index.html b/client/index.html
index ce8b904..99e1e3f 100644
--- a/client/index.html
+++ b/client/index.html
@@ -78,11 +78,22 @@
)
// Keyboard handler
- document.addEventListener('keydown', (event) => {
- const key = event.keyCode
- const { command, value } = keyMap[key]
- const endpoint = getEndpoint()
- sendCommand(endpoint, command, value)
+ document.addEventListener('keydown', ({ code }) => {
+ if (code === 'ArrowUp') {
+ return sendCommand(getEndpoint(), 'forward', 2)
+ }
+ if (code === 'ArrowDown') {
+ return sendCommand(getEndpoint(), 'backward', 2)
+ }
+ if (code === 'ArrowLeft') {
+ return sendCommand(getEndpoint(), 'left', 5)
+ }
+ if (code === 'ArrowRight') {
+ return sendCommand(getEndpoint(), 'right', 5)
+ }
+ if (code === 'Space') {
+ return sendCommand(getEndpoint(), 'stop', 0)
+ }
})
// Settings handler
@@ -197,18 +208,5 @@
}
return sendCommand(endpoint, positiveCommand, value)
}
-
- function storeInput() {
- ipInput = document.getElementById('ip').value
- valueRot = document.getElementById('valueRot').value
- valueLength = document.getElementById('valueLength').value
- keyMap = {
- 38: { command: 'forward', value: valueLength },
- 40: { command: 'backward', value: valueLength },
- 37: { command: 'left', value: valueRot },
- 39: { command: 'right', value: valueRot },
- 32: { command: 'stop', value: 0 },
- }
- }