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'.
This commit is contained in:
parent
8f8c1803ff
commit
4093c37f28
|
@ -106,8 +106,11 @@ Keyboard.prototype = {
|
||||||
// (don't use it for 'keypress' events thought since
|
// (don't use it for 'keypress' events thought since
|
||||||
// WebKit sets it to the same as charCode)
|
// WebKit sets it to the same as charCode)
|
||||||
if (e.keyCode && (e.type !== 'keypress')) {
|
if (e.keyCode && (e.type !== 'keypress')) {
|
||||||
|
// 229 is used for composition events
|
||||||
|
if (e.keyCode !== 229) {
|
||||||
return 'Platform' + e.keyCode;
|
return 'Platform' + e.keyCode;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// A precursor to the final DOM3 standard. Unfortunately it
|
// A precursor to the final DOM3 standard. Unfortunately it
|
||||||
// is not layout independent, so it is as bad as using keyCode
|
// is not layout independent, so it is as bad as using keyCode
|
||||||
|
|
|
@ -284,6 +284,14 @@ describe('Key Event Handling', function() {
|
||||||
kbd._handleKeyDown(keyevent('keydown', {keyCode: 65, key: 'a'}));
|
kbd._handleKeyDown(keyevent('keydown', {keyCode: 65, key: 'a'}));
|
||||||
kbd._handleKeyUp(keyevent('keyup', {keyCode: 65, key: 'b'}));
|
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) {
|
it('should track keys using keyIdentifier if no code', function(done) {
|
||||||
var kbd = new Keyboard({
|
var kbd = new Keyboard({
|
||||||
onKeyEvent: function(keysym, code, down) {
|
onKeyEvent: function(keysym, code, down) {
|
||||||
|
|
Loading…
Reference in New Issue