summaryrefslogtreecommitdiff
path: root/web/share/js/keypad.js
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2022-09-21 15:42:23 +0300
committerMaxim Devaev <[email protected]>2022-09-21 15:42:23 +0300
commitcb8534dfe72d0df4d13c36760c6d23bcd4bd0ff2 (patch)
tree2672f94a03300f000cc49f5b9ce756e07084723f /web/share/js/keypad.js
parent0ebd2da83d7441389f0a54ea47123acca5a8d4db (diff)
refactoring
Diffstat (limited to 'web/share/js/keypad.js')
-rw-r--r--web/share/js/keypad.js18
1 files changed, 12 insertions, 6 deletions
diff --git a/web/share/js/keypad.js b/web/share/js/keypad.js
index 90c1e652..797a351e 100644
--- a/web/share/js/keypad.js
+++ b/web/share/js/keypad.js
@@ -88,13 +88,19 @@ export function Keypad(__keys_parent, __sendKey, __apply_fixes) {
for (let dict of [__keys, __modifiers]) {
for (let code in dict) {
if (__isActive(dict[code][0])) {
- self.emit(code, false);
+ self.emitByCode(code, false);
}
}
}
};
- self.emit = function(code, state, apply_fixes=true) {
+ self.emitByKeyEvent = function(event, state) {
+ if (!event.repeat) {
+ self.emitByCode(event.code, state);
+ }
+ };
+
+ self.emitByCode = function(code, state, apply_fixes=true) {
if (code in __merged) {
if (__fix_win_altgr && apply_fixes) {
if (!__fixWinAltgr(code, state)) {
@@ -116,7 +122,7 @@ export function Keypad(__keys_parent, __sendKey, __apply_fixes) {
for (let code in __keys) {
setTimeout(function() {
if (__isActive(__keys[code][0])) {
- self.emit(code, false, false);
+ self.emitByCode(code, false, false);
}
}, 100);
}
@@ -131,13 +137,13 @@ export function Keypad(__keys_parent, __sendKey, __apply_fixes) {
clearTimeout(__altgr_ctrl_timer);
__altgr_ctrl_timer = null;
if (code !== "AltRight") {
- self.emit("ControlLeft", true, false);
+ self.emitByCode("ControlLeft", true, false);
}
}
if (code === "ControlLeft" && !__isActive(__modifiers["ControlLeft"][0])) {
__altgr_ctrl_timer = setTimeout(function() {
__altgr_ctrl_timer = null;
- self.emit("ControlLeft", true, false);
+ self.emitByCode("ControlLeft", true, false);
}, 50);
return false; // Stop handling
}
@@ -145,7 +151,7 @@ export function Keypad(__keys_parent, __sendKey, __apply_fixes) {
if (__altgr_ctrl_timer) {
clearTimeout(__altgr_ctrl_timer);
__altgr_ctrl_timer = null;
- self.emit("ControlLeft", true, false);
+ self.emitByCode("ControlLeft", true, false);
}
}
return true; // Continue handling