generated docs: avoid clobbering browser shortcut keys

This commit is contained in:
Andrew Kelley 2019-10-09 18:28:50 -04:00
parent 000a1df4a3
commit 510b6443ba
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9

View File

@ -1074,6 +1074,8 @@
function onSearchKeyDown(ev) {
switch (ev.which) {
case 13:
if (ev.shiftKey || ev.ctrlKey || ev.altKey) return;
// detect if this search changes anything
var terms1 = getSearchTerms();
startSearch();
@ -1087,6 +1089,8 @@
ev.stopPropagation();
return;
case 27:
if (ev.shiftKey || ev.ctrlKey || ev.altKey) return;
domSearch.value = "";
domSearch.blur();
curSearchIndex = -1;
@ -1095,16 +1099,22 @@
startSearch();
return;
case 38:
if (ev.shiftKey || ev.ctrlKey || ev.altKey) return;
moveSearchCursor(-1);
ev.preventDefault();
ev.stopPropagation();
return;
case 40:
if (ev.shiftKey || ev.ctrlKey || ev.altKey) return;
moveSearchCursor(1);
ev.preventDefault();
ev.stopPropagation();
return;
default:
if (ev.shiftKey || ev.ctrlKey || ev.altKey) return;
curSearchIndex = -1;
ev.stopPropagation();
startAsyncSearch();
@ -1134,6 +1144,7 @@
function onWindowKeyDown(ev) {
switch (ev.which) {
case 27:
if (ev.shiftKey || ev.ctrlKey || ev.altKey) return;
if (!domHelpModal.classList.contains("hidden")) {
domHelpModal.classList.add("hidden");
ev.preventDefault();
@ -1141,6 +1152,7 @@
}
break;
case 83:
if (ev.shiftKey || ev.ctrlKey || ev.altKey) return;
domSearch.focus();
domSearch.select();
ev.preventDefault();
@ -1148,6 +1160,7 @@
startAsyncSearch();
break;
case 191:
if (!ev.shiftKey || ev.ctrlKey || ev.altKey) return;
ev.preventDefault();
ev.stopPropagation();
showHelpModal();