From: Mark Wooding Date: Thu, 22 Jun 2023 11:15:59 +0000 (+0100) Subject: static/tgal.js (keyevent): Discard key events with spurious modifiers. X-Git-Url: https://git.distorted.org.uk/~mdw/tgal/commitdiff_plain static/tgal.js (keyevent): Discard key events with spurious modifiers. Allow shift with `^', `<' and `>' because they require that on common keyboard layouts (though not always), and because pressing shift gives a different result if it's not needed; forbid modifiers with cursor keys, space, and backspace. --- diff --git a/static/tgal.js b/static/tgal.js index 33f380d..6e96dc2 100644 --- a/static/tgal.js +++ b/static/tgal.js @@ -27,11 +27,13 @@ /* Handle keyboard interaction. */ addEventListener("keydown", function (ev) { var dir; - if (ev.key === " " || ev.key === "ArrowRight") dir = "next"; - else if (ev.key === "Backspace" || ev.key === "ArrowLeft") dir = "prev"; - else if (ev.key === "^") dir = "up"; + if (ev.altKey || ev.ctrlKey || ev.metaKey) return; else if (ev.key === "<") dir = "first"; else if (ev.key === ">") dir = "last"; + else if (ev.key === "^") dir = "up"; + else if (ev.shiftKey) return; + else if (ev.key === " " || ev.key === "ArrowRight") dir = "next"; + else if (ev.key === "Backspace" || ev.key === "ArrowLeft") dir = "prev"; else return; var elt = document.querySelector("link[rel=" + dir + "]"); if (!elt) return;