diff options
Diffstat (limited to 'web/share/js/keypad.js')
-rw-r--r-- | web/share/js/keypad.js | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/web/share/js/keypad.js b/web/share/js/keypad.js index 9efa3407..554e43cf 100644 --- a/web/share/js/keypad.js +++ b/web/share/js/keypad.js @@ -69,30 +69,42 @@ export function Keypad(keys_parent, key_callback) { /************************************************************************/ - self.releaseAll = function(release_hook=false) { + self.releaseAll = function() { for (let dict of [__keys, __modifiers]) { for (let code in dict) { if (__isActive(dict[code][0])) { - self.emit(code, false, release_hook); + self.emit(code, false); } } } }; - self.emit = function(code, state, release_hook=false) { + self.emit = function(code, state, fix_mac_cmd=false) { if (code in __merged) { __commonHandler(__merged[code][0], state, false); - if (release_hook) { - for (let code in __keys) { + if (fix_mac_cmd) { + __fixMacCmd(); + } + __unholdModifiers(); + } + }; + + var __fixMacCmd = function() { + if (__isMacCmdActive()) { + for (let code in __keys) { + setTimeout(function() { if (__isActive(__keys[code][0])) { self.emit(code, false); } - } + }, 100); } - __unholdModifiers(); } }; + var __isMacCmdActive = function() { + return (__isActive(__modifiers["MetaLeft"][0]) || __isActive(__modifiers["MetaRight"][0])); + }; + var __clickHandler = function(el_key, state) { __commonHandler(el_key, state, false); __unholdModifiers(); |