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