]> git.proxmox.com Git - mirror_novnc.git/commitdiff
Ignore compositing key
authorPierre Ossman <ossman@cendio.se>
Fri, 7 Jul 2017 13:04:44 +0000 (15:04 +0200)
committerPierre Ossman <ossman@cendio.se>
Fri, 7 Jul 2017 13:04:44 +0000 (15:04 +0200)
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'.

core/input/devices.js
tests/test.keyboard.js

index 575d57ace5de0bc5efe941ea778199880f171ff0..ae09c7f87b452f08d0508fd525bd7e89b8133fd3 100644 (file)
@@ -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
index 4fcd2fea556406c5307b2886d95d97bf56804e02..3585591c906ab1e3bf39fa93b1005197bf2aca69 100644 (file)
@@ -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) {