diff options
author | 2018-10-21 18:32:07 -0700 | |
---|---|---|
committer | 2018-10-21 18:32:07 -0700 | |
commit | 9440bf47a521a61c91073425bd613710cf7dd1cb (patch) | |
tree | 976d5d56cc569e7c3c1aa50531138e03728e7fe4 /ui/static/js/keyboard_handler.js | |
parent | 8c65c78904225e92df045cac43700210936ca148 (diff) | |
download | v2-9440bf47a521a61c91073425bd613710cf7dd1cb.tar.gz v2-9440bf47a521a61c91073425bd613710cf7dd1cb.tar.zst v2-9440bf47a521a61c91073425bd613710cf7dd1cb.zip |
Call preventDefault() when a keyboard shortcut is executed
Diffstat (limited to 'ui/static/js/keyboard_handler.js')
-rw-r--r-- | ui/static/js/keyboard_handler.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/ui/static/js/keyboard_handler.js b/ui/static/js/keyboard_handler.js index df6eefc9..e30b0ddc 100644 --- a/ui/static/js/keyboard_handler.js +++ b/ui/static/js/keyboard_handler.js @@ -21,14 +21,12 @@ class KeyboardHandler { let keys = combination.split(" "); if (keys.every((value, index) => value === this.queue[index])) { - this.queue = []; - this.shortcuts[combination](event); + this.execute(combination, event); return; } if (keys.length === 1 && key === keys[0]) { - this.queue = []; - this.shortcuts[combination](event); + this.execute(combination, event); return; } } @@ -39,6 +37,14 @@ class KeyboardHandler { }; } + execute(combination, event) { + event.preventDefault(); + event.stopPropagation(); + + this.queue = []; + this.shortcuts[combination](event); + } + isEventIgnored(event) { return event.target.tagName === "INPUT" || event.target.tagName === "TEXTAREA"; } |