Commit 640778c2 authored by Douglas Gore's avatar Douglas Gore

Standards compliant key handling

Move key handling away from keyIdentifier (deprecated) and use key
instead for cross browser compatibility. Tested on Chrome, Firefox and
Edge.
parent ebe8c0e6
......@@ -32,32 +32,36 @@ function updateUltrasonic() {
function keyEvent(e) {
var url;
console.log("Key pressed id = " + e.keyIdentifier);
console.log("Key pressed id = " + e.key);
switch(e.keyIdentifier) {
switch(e.key) {
case "ArrowLeft":
case "Left":
url = "/left";
break;
case "ArrowRight":
case "Right":
url = "/right";
break;
case "ArrowUp":
case "Up":
url = "/forwards";
break;
case "ArrowDown":
case "Down":
url = "/backwards";
break;
case "U+0043":
case "c":
document.getElementById("status").innerHTML = "Acquiring image sensor data...";
document.getElementById("camera").src = "";
document.getElementById("camera").src = "/cheese";
break;
case "U+0055":
case "u":
config.ultrasonics = !config.ultrasonics;
if (config.ultrasonics) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment