Fix issue #326: correct handling of shift key
When shortcut modifiers (modifier keys such as CTRL, which do not participate in composing character input) are pressed, we try to suppress the keypress event, as browsers do not reliably generate it. This means that subsequent key events are decoded only based on the keydown event. Due to a type error (comparing a string to a number), shift was mistakenly treated as a shortcut modifier, preventing text input which relied on shift, such as _ and %, from being generated.
This commit is contained in:
parent
85e8991664
commit
f6a1d98a3a
|
@ -31,7 +31,7 @@ var kbdUtil = (function() {
|
||||||
function hasShortcutModifier(charModifier, currentModifiers) {
|
function hasShortcutModifier(charModifier, currentModifiers) {
|
||||||
var mods = {};
|
var mods = {};
|
||||||
for (var key in currentModifiers) {
|
for (var key in currentModifiers) {
|
||||||
if (key !== 0xffe1) {
|
if (parseInt(key) !== 0xffe1) {
|
||||||
mods[key] = currentModifiers[key];
|
mods[key] = currentModifiers[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,5 +248,13 @@ describe('Helpers', function() {
|
||||||
})).to.be.deep.equal([{keysym: keysyms.lookup(0xffe9), type: 'keydown'}]);
|
})).to.be.deep.equal([{keysym: keysyms.lookup(0xffe9), type: 'keydown'}]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('do not treat shift as a modifier key', function() {
|
||||||
|
it('should not treat shift as a shortcut modifier', function() {
|
||||||
|
expect(kbdUtil.hasShortcutModifier([], {0xffe1 : true})).to.be.false;
|
||||||
|
});
|
||||||
|
it('should not treat shift as a char modifier', function() {
|
||||||
|
expect(kbdUtil.hasCharModifier([], {0xffe1 : true})).to.be.false;
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue