Handle broken numpad delete key in Chrome
This commit is contained in:
parent
dd4341fe67
commit
9d956e9198
|
@ -103,6 +103,11 @@ export function getKey(evt) {
|
||||||
case 'UIKeyInputEscape': return 'Escape';
|
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
|
// IE and Edge have broken handling of AltGraph so we cannot
|
||||||
// trust them for printable characters
|
// trust them for printable characters
|
||||||
if ((evt.key.length !== 1) || (!browser.isIE() && !browser.isEdge())) {
|
if ((evt.key.length !== 1) || (!browser.isIE() && !browser.isEdge())) {
|
||||||
|
|
|
@ -110,6 +110,9 @@ describe('Helpers', function () {
|
||||||
expect(KeyboardUtil.getKey({key: 'Win'})).to.be.equal('Meta');
|
expect(KeyboardUtil.getKey({key: 'Win'})).to.be.equal('Meta');
|
||||||
expect(KeyboardUtil.getKey({key: 'UIKeyInputLeftArrow'})).to.be.equal('ArrowLeft');
|
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 () {
|
it('should use code if no key', function () {
|
||||||
expect(KeyboardUtil.getKey({code: 'NumpadBackspace'})).to.be.equal('Backspace');
|
expect(KeyboardUtil.getKey({code: 'NumpadBackspace'})).to.be.equal('Backspace');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue