mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
js: Add actions for more keys in menus
I expect Escape to exit the menu, and SoftRight should do that as well for KaiOS. Backspace goes up one level through the menus, again because that's conventional on KaiOS and not too confusing elsewhere.
This commit is contained in:
@ -458,7 +458,8 @@ function initPuzzle() {
|
||||
var cs = window.getComputedStyle(menu);
|
||||
return cs.display == "flex" && cs.flexDirection == "row";
|
||||
}
|
||||
if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Enter"]
|
||||
if (!["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown", "Enter",
|
||||
"Escape", "Backspace", "SoftRight"]
|
||||
.includes(event.key))
|
||||
return;
|
||||
if (ishorizontal(thismenu)) {
|
||||
@ -494,11 +495,17 @@ function initPuzzle() {
|
||||
else if (event.key == "ArrowLeft")
|
||||
targetitem = parentitem_sideways ||
|
||||
(parentitem_up && prevmenuitem(parentitem_up));
|
||||
else if (event.key == "Backspace")
|
||||
targetitem = parentitem;
|
||||
}
|
||||
if (targetitem)
|
||||
targetitem.firstElementChild.focus();
|
||||
else if (event.key == "Enter")
|
||||
event.target.click();
|
||||
else if (event.key == "Escape" || event.key == "SoftRight" ||
|
||||
event.key == "Backspace")
|
||||
// Leave the menu entirely.
|
||||
onscreen_canvas.focus();
|
||||
// Prevent default even if we didn't do anything, as long as this
|
||||
// was an interesting key.
|
||||
event.preventDefault();
|
||||
|
Reference in New Issue
Block a user