handle escape hotkey earlier, even in input
Ted Unangst tedu@tedunangst.com
Mon, 19 Feb 2024 23:02:02 -0500
1 files changed,
7 insertions(+),
6 deletions(-)
jump to
M
views/honkpage.js
→
views/honkpage.js
@@ -456,9 +456,14 @@ }
} function hotkey(e) { - if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) + if (e.ctrlKey || e.altKey) + return + if (e.code == "Escape") { + var menu = document.getElementById("topmenu") + menu.open = false return - if (e.ctrlKey || e.altKey) + } + if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) return switch (e.code) {@@ -482,10 +487,6 @@ menu.querySelector("a").focus()
} else { menu.open = false } - break - case "Escape": - var menu = document.getElementById("topmenu") - menu.open = false break case "Slash": document.getElementById("topmenu").open = true