diff --git a/examples/web_interface.html b/examples/web_interface.html
index 97ee3c8..5d3583a 100644
--- a/examples/web_interface.html
+++ b/examples/web_interface.html
@@ -45,17 +45,41 @@
Disconnected
-
+
+
+ Use W, A, S, D to move/turn.
+ Press Q to stop movement.
+ Releasing any key also stops the robot.
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -116,6 +140,40 @@
}
});
+ function onKeyDown(event) {
+ const key = event.key.toLowerCase();
+ switch (key) {
+ case 'w':
+ sendVelocity(0.5, 0.0);
+ break;
+ case 's':
+ sendVelocity(-0.5, 0.0);
+ break;
+ case 'a':
+ sendVelocity(0.0, 45.0);
+ break;
+ case 'd':
+ sendVelocity(0.0, -45.0);
+ break;
+ case 'q':
+ sendVelocity(0.0, 0.0);
+ break;
+ default:
+ break;
+ }
+ }
+
+ function onKeyUp(event) {
+ const key = event.key.toLowerCase();
+ if (['w','a','s','d','arrowup','arrowdown','arrowleft','arrowright'].includes(key)) {
+ sendVelocity(0.0, 0.0);
+ }
+ }
+
+ document.addEventListener('keydown', onKeyDown);
+ document.addEventListener('keyup', onKeyUp);
+
+
function updateVelocity() {
// Calculate linear velocity (forward/backward)
let linear = 0;