shithub: puzzles

Download patch

ref: b8e9bfa7f6a1d96e8cae96f43d7b5a1394abb447
parent: b6f783e26e9d692dc2243bf5cf945cc0717c00aa
author: Ben Harris <[email protected]>
date: Sun Jan 1 18:29:25 EST 2023

kaios: Make F10 open and close the menu

This is no use on KaiOS itself, but provides a way to open the menu from
the keyboard on desktop browsers for testing (and for
keyboard-accessibility in general).

--- a/emccpre.js
+++ b/emccpre.js
@@ -491,7 +491,7 @@
         if (dlg_dimmer !== null)
             return;
         if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Enter",
-              "Escape", "Backspace", "SoftRight"]
+              "Escape", "Backspace", "SoftRight", "F10"]
             .includes(event.key))
             return;
         if (ishorizontal(thismenu)) {
@@ -535,7 +535,7 @@
         else if (event.key == "Enter")
             event.target.click();
         else if (event.key == "Escape" || event.key == "SoftRight" ||
-                 event.key == "Backspace")
+                 event.key == "F10" || event.key == "Backspace")
             // Leave the menu entirely.
             onscreen_canvas.focus();
         // Prevent default even if we didn't do anything, as long as this
@@ -599,7 +599,7 @@
 
     document.addEventListener("keydown", function(event) {
         // Key to open the menu on KaiOS.
-        if (event.key == "SoftRight" &&
+        if ((event.key == "SoftRight" || event.key == "F10") &&
             !menuform.contains(document.activeElement)) {
             menuform.querySelector("li div").focus();
             event.preventDefault();