diff options
author | Pierre Ossman <ossman@cendio.se> | 2019-10-31 14:51:36 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2019-10-31 14:51:36 +0100 |
commit | 9d956e919834ca0877f993d30a05cd8e3d182aca (patch) | |
tree | 7079de6f9180ef8289a7728b890f72316597fe16 | |
parent | dd4341fe6774dcbf64bf76a9f3a32d86d660a45e (diff) | |
download | novnc-9d956e919834ca0877f993d30a05cd8e3d182aca.tar.gz |
Handle broken numpad delete key in Chrome
-rw-r--r-- | core/input/util.js | 5 | ||||
-rw-r--r-- | tests/test.helper.js | 3 |
2 files changed, 8 insertions, 0 deletions
diff --git a/core/input/util.js b/core/input/util.js index 179f7ee..b0e8855 100644 --- a/core/input/util.js +++ b/core/input/util.js @@ -103,6 +103,11 @@ export function getKey(evt) { case 'UIKeyInputEscape': return 'Escape'; } + // Broken behaviour in Chrome + if ((evt.key === '\x00') && (evt.code === 'NumpadDecimal')) { + return 'Delete'; + } + // IE and Edge have broken handling of AltGraph so we cannot // trust them for printable characters if ((evt.key.length !== 1) || (!browser.isIE() && !browser.isEdge())) { diff --git a/tests/test.helper.js b/tests/test.helper.js index 5b58a83..70eba1b 100644 --- a/tests/test.helper.js +++ b/tests/test.helper.js @@ -110,6 +110,9 @@ describe('Helpers', function () { expect(KeyboardUtil.getKey({key: 'Win'})).to.be.equal('Meta'); expect(KeyboardUtil.getKey({key: 'UIKeyInputLeftArrow'})).to.be.equal('ArrowLeft'); }); + it('should handle broken Delete', function () { + expect(KeyboardUtil.getKey({key: '\x00', code: 'NumpadDecimal'})).to.be.equal('Delete'); + }); it('should use code if no key', function () { expect(KeyboardUtil.getKey({code: 'NumpadBackspace'})).to.be.equal('Backspace'); }); |