summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2019-10-31 14:07:30 +0100
committerPierre Ossman <ossman@cendio.se>2019-10-31 14:12:58 +0100
commit758399050deda24132a8c9e24ef9d552283abe99 (patch)
treedee920ee44cb42b0fc9d26dbb2c2b1b8b4df6d52
parent1dd1bf0306c12b768af4238f0b7ea68feaac9d8f (diff)
downloadnovnc-758399050deda24132a8c9e24ef9d552283abe99.tar.gz
Try to handle Meta key properly
The standards have unfortunatly caused some confusion between the Windows key and the original Meta key. Try to handle the common case sanely at least.
-rw-r--r--core/input/util.js13
-rw-r--r--tests/test.helper.js6
2 files changed, 19 insertions, 0 deletions
diff --git a/core/input/util.js b/core/input/util.js
index f177ef5..179f7ee 100644
--- a/core/input/util.js
+++ b/core/input/util.js
@@ -1,3 +1,4 @@
+import KeyTable from "./keysym.js";
import keysyms from "./keysymdef.js";
import vkeys from "./vkeys.js";
import fixedkeys from "./fixedkeys.js";
@@ -145,6 +146,18 @@ export function getKeysym(evt) {
location = 0;
}
+ // The original Meta key now gets confused with the Windows key
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=1020141
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=1232918
+ if (key === 'Meta') {
+ let code = getKeycode(evt);
+ if (code === 'AltLeft') {
+ return KeyTable.XK_Meta_L;
+ } else if (code === 'AltRight') {
+ return KeyTable.XK_Meta_R;
+ }
+ }
+
return DOMKeyTable[key][location];
}
diff --git a/tests/test.helper.js b/tests/test.helper.js
index d44bab0..5b58a83 100644
--- a/tests/test.helper.js
+++ b/tests/test.helper.js
@@ -192,6 +192,12 @@ describe('Helpers', function () {
expect(KeyboardUtil.getKeysym({code: 'AltRight', key: 'Alt', location: 2})).to.be.equal(0xFFEA);
expect(KeyboardUtil.getKeysym({code: 'AltRight', key: 'AltGraph', location: 2})).to.be.equal(0xFE03);
});
+ it('should handle Meta/Windows distinction', function () {
+ expect(KeyboardUtil.getKeysym({code: 'AltLeft', key: 'Meta', location: 1})).to.be.equal(0xFFE7);
+ expect(KeyboardUtil.getKeysym({code: 'AltRight', key: 'Meta', location: 2})).to.be.equal(0xFFE8);
+ expect(KeyboardUtil.getKeysym({code: 'MetaLeft', key: 'Meta', location: 1})).to.be.equal(0xFFEB);
+ expect(KeyboardUtil.getKeysym({code: 'MetaRight', key: 'Meta', location: 2})).to.be.equal(0xFFEC);
+ });
it('should return null for unknown keys', function () {
expect(KeyboardUtil.getKeysym({key: 'Semicolon'})).to.be.null;
expect(KeyboardUtil.getKeysym({key: 'BracketRight'})).to.be.null;