diff options
author | Pierre Ossman <ossman@cendio.se> | 2017-07-07 15:04:44 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2017-07-07 15:04:44 +0200 |
commit | 4093c37f28d57424554100150bdf5c90e1959ff5 (patch) | |
tree | 536029e84be596987958c6791ab197cef9524fe6 | |
parent | 8f8c1803ffb25f6ed491279fa6f3fb4f4934e710 (diff) | |
download | novnc-4093c37f28d57424554100150bdf5c90e1959ff5.tar.gz |
Ignore compositing key
keyCode 229 is commonly used with virtual keyboards when the
system cannot map things to a specific key. As such we should
treat it as 'Unidentified'.
-rw-r--r-- | core/input/devices.js | 5 | ||||
-rw-r--r-- | tests/test.keyboard.js | 8 |
2 files changed, 12 insertions, 1 deletions
diff --git a/core/input/devices.js b/core/input/devices.js index 575d57a..ae09c7f 100644 --- a/core/input/devices.js +++ b/core/input/devices.js @@ -106,7 +106,10 @@ Keyboard.prototype = { // (don't use it for 'keypress' events thought since // WebKit sets it to the same as charCode) if (e.keyCode && (e.type !== 'keypress')) { - return 'Platform' + e.keyCode; + // 229 is used for composition events + if (e.keyCode !== 229) { + return 'Platform' + e.keyCode; + } } // A precursor to the final DOM3 standard. Unfortunately it diff --git a/tests/test.keyboard.js b/tests/test.keyboard.js index 4fcd2fe..3585591 100644 --- a/tests/test.keyboard.js +++ b/tests/test.keyboard.js @@ -284,6 +284,14 @@ describe('Key Event Handling', function() { kbd._handleKeyDown(keyevent('keydown', {keyCode: 65, key: 'a'})); kbd._handleKeyUp(keyevent('keyup', {keyCode: 65, key: 'b'})); }); + it('should ignore compositing code', function() { + var kbd = new Keyboard({ + onKeyEvent: function(keysym, code, down) { + expect(keysym).to.be.equal(0x61); + expect(code).to.be.equal('Unidentified'); + }}); + kbd._handleKeyDown(keyevent('keydown', {keyCode: 229, key: 'a'})); + }); it('should track keys using keyIdentifier if no code', function(done) { var kbd = new Keyboard({ onKeyEvent: function(keysym, code, down) { |