diff options
author | Devaev Maxim <[email protected]> | 2018-08-07 09:31:09 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2018-08-07 10:48:52 +0300 |
commit | 20f7e2cde675fe7c3bddbf62328ebe9a11d96e13 (patch) | |
tree | c03d18d10544d96b76e8a7653cd4765c89b5ba80 /kvmd/web/js/keyboard.js | |
parent | a6b9c81636aa29b1c0ccd9b3f01842c68ccf57b8 (diff) |
quick hack for mac cmd key
Diffstat (limited to 'kvmd/web/js/keyboard.js')
-rw-r--r-- | kvmd/web/js/keyboard.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/kvmd/web/js/keyboard.js b/kvmd/web/js/keyboard.js index 3618f447..de881f7a 100644 --- a/kvmd/web/js/keyboard.js +++ b/kvmd/web/js/keyboard.js @@ -1,4 +1,11 @@ var keyboard = new function() { + var __mac_cmd_hook = (( + window.navigator.oscpu + || window.navigator.platform + || window.navigator.appVersion + || "Unknown" + ).indexOf("Mac") !== -1); + var __ws = null; var __keys = []; var __modifiers = []; @@ -24,6 +31,10 @@ var keyboard = new function() { el_key.onmousedown = () => __toggleModifierHandler(el_key); __modifiers.push(el_key); }); + + if (__mac_cmd_hook) { + tools.info("Keyboard: enabled Mac-CMD-Hook"); + } }; this.setSocket = function(ws) { @@ -59,6 +70,18 @@ var keyboard = new function() { el_key = $(event.code); if (el_key && !event.repeat) { __commonHandler(el_key, state, "pressed"); + if (__mac_cmd_hook) { + // https://bugs.chromium.org/p/chromium/issues/detail?id=28089 + // https://bugzilla.mozilla.org/show_bug.cgi?id=1299553 + if ((event.code === "MetaLeft" || event.code === "MetaRight") && !state) { + __keys.forEach(function(el_key) { + if (__isActive(el_key)) { + // __commonHandler(el_key, false, "pressed"); + keyboard.fireEvent(el_key.id, false); + } + }); + } + } __unholdModifiers(); } }; |