Add docstring to should_prevent_hotkey.

This commit is contained in:
voussoir 2021-10-23 18:45:52 -07:00
parent 08a8095efb
commit 6fad61d49a
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB

View file

@ -44,6 +44,10 @@ function register_hotkey(hotkey, action, description)
hotkeys.should_prevent_hotkey = hotkeys.should_prevent_hotkey =
function should_prevent_hotkey(event) 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") if (event.target.tagName == "INPUT" && event.target.type == "checkbox")
{ {
return false; return false;
@ -71,7 +75,11 @@ function show_all_hotkeys()
hotkeys.hotkeys_listener = hotkeys.hotkeys_listener =
function hotkeys_listener(event) 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); identifier = hotkeys.hotkey_identifier(event.key, event.ctrlKey, event.shiftKey, event.altKey);
//console.log(identifier); //console.log(identifier);
if (identifier in hotkeys.HOTKEYS) if (identifier in hotkeys.HOTKEYS)