Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autodoc: Use code for keyboard events #19276

Merged
merged 1 commit into from Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions lib/docs/main.js
Expand Up @@ -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();
Expand All @@ -677,7 +677,7 @@
ev.preventDefault();
ev.stopPropagation();
return;
case 27:
case "Escape":
if (ev.shiftKey || ev.ctrlKey || ev.altKey) return;

domSearch.value = "";
Expand All @@ -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);
Expand Down Expand Up @@ -732,30 +732,30 @@
}

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");
ev.preventDefault();
ev.stopPropagation();
}
break;
case 83:
case "KeyS":
if (ev.shiftKey || ev.ctrlKey || ev.altKey) return;
domSearch.focus();
domSearch.select();
ev.preventDefault();
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();
Expand Down