mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 09:01:54 +08:00
refactoring
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user