summaryrefslogtreecommitdiff
path: root/ext/js/display
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/display')
-rw-r--r--ext/js/display/search-display-controller.js19
1 files changed, 9 insertions, 10 deletions
diff --git a/ext/js/display/search-display-controller.js b/ext/js/display/search-display-controller.js
index 9b2311d1..e63b96e8 100644
--- a/ext/js/display/search-display-controller.js
+++ b/ext/js/display/search-display-controller.js
@@ -154,16 +154,15 @@ export class SearchDisplayController {
* @param {KeyboardEvent} e
*/
_onKeyDown(e) {
- const {activeElement} = document;
- if (
- activeElement !== this._queryInput &&
- !this._isElementInput(activeElement) &&
- (!e.ctrlKey || e.key === 'Backspace') &&
- !e.metaKey &&
- !e.altKey &&
- (e.key.length === 1 || e.key === 'Backspace') &&
- e.key !== ' '
- ) {
+ const activeElement = document.activeElement;
+
+ const isInputField = this._isElementInput(activeElement);
+ const isAllowedKey = e.key.length === 1 || e.key === 'Backspace';
+ const isModifierKey = e.ctrlKey || e.metaKey || e.altKey;
+ const isSpaceKey = e.key === ' ';
+ const isCtrlBackspace = e.ctrlKey && e.key === 'Backspace';
+
+ if (!isInputField && (!isModifierKey || isCtrlBackspace) && isAllowedKey && !isSpaceKey) {
this._queryInput.focus({preventScroll: true});
}
}