summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/share/js/keypad.js22
-rw-r--r--web/share/js/kvm/keyboard.js19
2 files changed, 17 insertions, 24 deletions
diff --git a/web/share/js/keypad.js b/web/share/js/keypad.js
index 6c5ef006..39c4ab25 100644
--- a/web/share/js/keypad.js
+++ b/web/share/js/keypad.js
@@ -26,7 +26,7 @@
import {tools, $$$} from "./tools.js";
-export function Keypad(keys_parent, key_callback) {
+export function Keypad(__keys_parent, __sendKey, __fix_mac_cmd=false) {
var self = this;
/************************************************************************/
@@ -36,7 +36,7 @@ export function Keypad(keys_parent, key_callback) {
var __modifiers = {};
var __init__ = function() {
- for (let el_key of $$$(`${keys_parent} div.key`)) {
+ for (let el_key of $$$(`${__keys_parent} div.key`)) {
let code = el_key.getAttribute("data-code");
tools.setDefault(__keys, code, []);
@@ -54,7 +54,7 @@ export function Keypad(keys_parent, key_callback) {
};
}
- for (let el_key of $$$(`${keys_parent} div.modifier`)) {
+ for (let el_key of $$$(`${__keys_parent} div.modifier`)) {
let code = el_key.getAttribute("data-code");
tools.setDefault(__modifiers, code, []);
@@ -79,10 +79,10 @@ export function Keypad(keys_parent, key_callback) {
}
};
- self.emit = function(code, state, fix_mac_cmd=false) {
+ self.emit = function(code, state, apply_fixes=true) {
if (code in __merged) {
__commonHandler(__merged[code][0], state, false);
- if (fix_mac_cmd) {
+ if (__fix_mac_cmd && apply_fixes) {
__fixMacCmd();
}
__unholdModifiers();
@@ -90,21 +90,19 @@ export function Keypad(keys_parent, key_callback) {
};
var __fixMacCmd = function() {
- if (__isMacCmdActive()) {
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=28089
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1299553
+ if (__isActive(__modifiers["MetaLeft"][0]) || __isActive(__modifiers["MetaRight"][0])) {
for (let code in __keys) {
setTimeout(function() {
if (__isActive(__keys[code][0])) {
- self.emit(code, false);
+ self.emit(code, false, false);
}
}, 100);
}
}
};
- var __isMacCmdActive = function() {
- return (__isActive(__modifiers["MetaLeft"][0]) || __isActive(__modifiers["MetaRight"][0]));
- };
-
var __clickHandler = function(el_key, state) {
__commonHandler(el_key, state, false);
__unholdModifiers();
@@ -184,7 +182,7 @@ export function Keypad(keys_parent, key_callback) {
var __process = function(el_key, state) {
let code = el_key.getAttribute("data-code");
- key_callback(code, state);
+ __sendKey(code, state);
};
__init__();
diff --git a/web/share/js/kvm/keyboard.js b/web/share/js/kvm/keyboard.js
index e1368f3e..0cdfafda 100644
--- a/web/share/js/kvm/keyboard.js
+++ b/web/share/js/kvm/keyboard.js
@@ -33,10 +33,14 @@ export function Keyboard(__recordWsEvent) {
var __online = true;
var __keypad = null;
- var __fix_mac_cmd = false;
var __init__ = function() {
- __keypad = new Keypad("div#keyboard-window", __sendKey);
+ let fix_mac_cmd = tools.browser.is_mac;
+ if (fix_mac_cmd) {
+ tools.info("Keyboard: enabled Fix-Mac-CMD");
+ }
+
+ __keypad = new Keypad("div#keyboard-window", __sendKey, fix_mac_cmd);
$("hid-keyboard-led").title = "Keyboard free";
@@ -52,13 +56,6 @@ export function Keyboard(__recordWsEvent) {
window.addEventListener("focusin", __updateOnlineLeds);
window.addEventListener("focusout", __updateOnlineLeds);
-
- 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 Fix-Mac-CMD");
- __fix_mac_cmd = true;
- }
};
/************************************************************************/
@@ -135,9 +132,7 @@ export function Keyboard(__recordWsEvent) {
event.preventDefault();
}
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, __fix_mac_cmd);
+ __keypad.emit(event.code, state);
}
};