Limit use of keypress fallback

It was preventing key events for dead keys, so try to reduce it to
only cases where we must use it.
This commit is contained in:
Pierre Ossman 2017-06-02 14:38:16 +02:00
parent 459ed0083f
commit 844e983916
1 changed files with 9 additions and 1 deletions

View File

@ -44,6 +44,12 @@ function isMac() {
function isWindows() {
return navigator && !!(/win/i).exec(navigator.platform);
}
function isIE() {
return navigator && !!(/trident/i).exec(navigator.userAgent);
}
function isEdge() {
return navigator && !!(/edge/i).exec(navigator.userAgent);
}
Keyboard.prototype = {
// private methods
@ -159,7 +165,9 @@ Keyboard.prototype = {
// If this is a legacy browser then we'll need to wait for
// a keypress event as well
if (!keysym) {
// (IE and Edge has a broken KeyboardEvent.key, so we can't
// just check for the presence of that field)
if (!keysym && (!e.key || isIE() || isEdge())) {
this._pendingKey = code;
return;
}