From b8e9bfa7f6a1d96e8cae96f43d7b5a1394abb447 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sun, 1 Jan 2023 23:29:25 +0000 Subject: [PATCH] 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). --- emccpre.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/emccpre.js b/emccpre.js index cc7090a..6485d94 100644 --- a/emccpre.js +++ b/emccpre.js @@ -491,7 +491,7 @@ function initPuzzle() { 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 @@ function initPuzzle() { 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 @@ function initPuzzle() { 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();