summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2021-03-13 20:01:43 +0300
committerDevaev Maxim <[email protected]>2021-03-13 20:01:43 +0300
commit1c1bb3b2e6fa7431aaad6b05688b5b591ada2617 (patch)
treee9e151a59fefdbddd244be8a87e345f2da18d1b6 /web
parentde3a14467377d0a33303304b6787b4c4151b0e0c (diff)
better mac cmd handling
Diffstat (limited to 'web')
-rw-r--r--web/share/js/keypad.js26
-rw-r--r--web/share/js/kvm/keyboard.js10
2 files changed, 24 insertions, 12 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();
diff --git a/web/share/js/kvm/keyboard.js b/web/share/js/kvm/keyboard.js
index e1491b4e..d9241ae3 100644
--- a/web/share/js/kvm/keyboard.js
+++ b/web/share/js/kvm/keyboard.js
@@ -35,7 +35,7 @@ export function Keyboard(record_callback) {
var __online = true;
var __keypad = null;
- var __use_release_hook = false;
+ var __fix_mac_cmd = false;
var __init__ = function() {
__keypad = new Keypad("div#keyboard-window", __sendKey);
@@ -58,8 +58,8 @@ export function Keyboard(record_callback) {
if (tools.browser.is_mac) {
// https://bugs.chromium.org/p/chromium/issues/detail?id=28089
// https://bugzilla.mozilla.org/show_bug.cgi?id=1299553
- tools.info("Keyboard: enabled Mac-CMD-Hook");
- __use_release_hook = true;
+ tools.info("Keyboard: enabled Fix-Mac-CMD");
+ __fix_mac_cmd = true;
}
};
@@ -95,7 +95,7 @@ export function Keyboard(record_callback) {
};
self.releaseAll = function() {
- __keypad.releaseAll(__use_release_hook);
+ __keypad.releaseAll();
};
self.emit = function(code, state) {
@@ -139,7 +139,7 @@ export function Keyboard(record_callback) {
if (!event.repeat) {
// https://bugs.chromium.org/p/chromium/issues/detail?id=28089
// https://bugzilla.mozilla.org/show_bug.cgi?id=1299553
- __keypad.emit(event.code, state, __use_release_hook);
+ __keypad.emit(event.code, state, __fix_mac_cmd);
}
};