summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2022-09-21 18:27:51 +0300
committerMaxim Devaev <[email protected]>2022-09-21 18:27:51 +0300
commit55eab2df0dc8ccbcd7779fa0d721cb5e492f2d2b (patch)
treedbdd6119a2d1632ff8d5b978970c58ead2902074
parentcb8534dfe72d0df4d13c36760c6d23bcd4bd0ff2 (diff)
pikvm/pikvm#819: fix for Apple Magic Keyboard and non-Safari
-rw-r--r--web/share/js/keypad.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/web/share/js/keypad.js b/web/share/js/keypad.js
index 797a351e..5140ec8f 100644
--- a/web/share/js/keypad.js
+++ b/web/share/js/keypad.js
@@ -95,9 +95,21 @@ export function Keypad(__keys_parent, __sendKey, __apply_fixes) {
};
self.emitByKeyEvent = function(event, state) {
- if (!event.repeat) {
- self.emitByCode(event.code, state);
+ if (event.repeat) {
+ return;
}
+
+ let code = event.code;
+ if (__apply_fixes) {
+ // https://github.com/pikvm/pikvm/issues/819
+ if (code == "IntlBackslash" && event.key in ["`", "~"]) {
+ code = "Backquote";
+ } else if (code == "Backquote" && event.key in ["§", "±"]) {
+ code = "IntlBackslash";
+ }
+ }
+
+ self.emitByCode(code, state);
};
self.emitByCode = function(code, state, apply_fixes=true) {