From 6fad61d49a6700fdb324f9dffdbd10e45295edd6 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 23 Oct 2021 18:45:52 -0700 Subject: [PATCH] Add docstring to should_prevent_hotkey. --- frontends/etiquette_flask/static/js/hotkeys.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/frontends/etiquette_flask/static/js/hotkeys.js b/frontends/etiquette_flask/static/js/hotkeys.js index b595791..daa6442 100644 --- a/frontends/etiquette_flask/static/js/hotkeys.js +++ b/frontends/etiquette_flask/static/js/hotkeys.js @@ -44,6 +44,10 @@ function register_hotkey(hotkey, action, description) hotkeys.should_prevent_hotkey = function should_prevent_hotkey(event) { + /* + If the user is currently in an input element, then the registered hotkey + will be ignored and the browser will use its default behavior. + */ if (event.target.tagName == "INPUT" && event.target.type == "checkbox") { return false; @@ -71,7 +75,11 @@ function show_all_hotkeys() hotkeys.hotkeys_listener = function hotkeys_listener(event) { - if (hotkeys.should_prevent_hotkey(event)) { return; } + if (hotkeys.should_prevent_hotkey(event)) + { + return; + } + identifier = hotkeys.hotkey_identifier(event.key, event.ctrlKey, event.shiftKey, event.altKey); //console.log(identifier); if (identifier in hotkeys.HOTKEYS)