KeyboardNavigation prevented when text input focused

This commit is contained in:
nklhrstv 2020-03-17 14:57:49 +02:00
parent 838ad18f9f
commit a89e04192f

View file

@ -2,11 +2,15 @@ function KeyboardNavigation() {
let active = false;
function onKeyDown(event) {
if (event.keyboardNavigationPrevented) {
if (event.keyboardNavigationPrevented || event.target.tagName === 'INPUT') {
return;
}
switch (event.code) {
case 'Digit0': {
window.location = '#/search';
break;
}
case 'Digit1': {
window.location = '#/';
break;
@ -28,12 +32,10 @@ function KeyboardNavigation() {
break;
}
case 'Backspace': {
if (event.target.tagName !== 'INPUT') {
if (event.ctrlKey) {
window.history.forward();
} else {
window.history.back();
}
if (event.ctrlKey) {
window.history.forward();
} else {
window.history.back();
}
break;