autodoc: Use code for keyboard events

This commit is contained in:
Carl Åstholm 2024-03-12 19:54:49 +01:00 committed by Andrew Kelley
parent 7a858257f2
commit 2008b14bc7

View File

@ -666,8 +666,8 @@
} }
function onSearchKeyDown(ev) { function onSearchKeyDown(ev) {
switch (ev.which) { switch (ev.code) {
case 13: case "Enter":
if (ev.shiftKey || ev.ctrlKey || ev.altKey) return; if (ev.shiftKey || ev.ctrlKey || ev.altKey) return;
clearAsyncSearch(); clearAsyncSearch();
@ -677,7 +677,7 @@
ev.preventDefault(); ev.preventDefault();
ev.stopPropagation(); ev.stopPropagation();
return; return;
case 27: case "Escape":
if (ev.shiftKey || ev.ctrlKey || ev.altKey) return; if (ev.shiftKey || ev.ctrlKey || ev.altKey) return;
domSearch.value = ""; domSearch.value = "";
@ -687,14 +687,14 @@
ev.stopPropagation(); ev.stopPropagation();
startSearch(); startSearch();
return; return;
case 38: case "ArrowUp":
if (ev.shiftKey || ev.ctrlKey || ev.altKey) return; if (ev.shiftKey || ev.ctrlKey || ev.altKey) return;
moveSearchCursor(-1); moveSearchCursor(-1);
ev.preventDefault(); ev.preventDefault();
ev.stopPropagation(); ev.stopPropagation();
return; return;
case 40: case "ArrowDown":
if (ev.shiftKey || ev.ctrlKey || ev.altKey) return; if (ev.shiftKey || ev.ctrlKey || ev.altKey) return;
moveSearchCursor(1); moveSearchCursor(1);
@ -732,8 +732,8 @@
} }
function onWindowKeyDown(ev) { function onWindowKeyDown(ev) {
switch (ev.which) { switch (ev.code) {
case 27: case "Escape":
if (ev.shiftKey || ev.ctrlKey || ev.altKey) return; if (ev.shiftKey || ev.ctrlKey || ev.altKey) return;
if (!domHelpModal.classList.contains("hidden")) { if (!domHelpModal.classList.contains("hidden")) {
domHelpModal.classList.add("hidden"); domHelpModal.classList.add("hidden");
@ -741,7 +741,7 @@
ev.stopPropagation(); ev.stopPropagation();
} }
break; break;
case 83: case "KeyS":
if (ev.shiftKey || ev.ctrlKey || ev.altKey) return; if (ev.shiftKey || ev.ctrlKey || ev.altKey) return;
domSearch.focus(); domSearch.focus();
domSearch.select(); domSearch.select();
@ -749,13 +749,13 @@
ev.stopPropagation(); ev.stopPropagation();
startAsyncSearch(); startAsyncSearch();
break; break;
case 85: case "KeyU":
if (ev.shiftKey || ev.ctrlKey || ev.altKey) return; if (ev.shiftKey || ev.ctrlKey || ev.altKey) return;
ev.preventDefault(); ev.preventDefault();
ev.stopPropagation(); ev.stopPropagation();
navigateToSource(); navigateToSource();
break; break;
case 191: case "Slash":
if (!ev.shiftKey || ev.ctrlKey || ev.altKey) return; if (!ev.shiftKey || ev.ctrlKey || ev.altKey) return;
ev.preventDefault(); ev.preventDefault();
ev.stopPropagation(); ev.stopPropagation();