Revert to a more conservative approach when mapping key events to scan codes
This commit is contained in:
parent
b6984d348e
commit
f6b4cb046e
5 changed files with 1265 additions and 1265 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -139,6 +139,15 @@ function Keyboard(parmsKbd)
|
||||||
|
|
||||||
Component.subclass(Component, Keyboard);
|
Component.subclass(Component, Keyboard);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* HACK: We set ALL_ONDOWN to false to ignore all down/up events for keys not explicitly marked as ONDOWN;
|
||||||
|
* even though that prevents those keys from being repeated properly (ie, at the simulation's repeat rate
|
||||||
|
* rather than the browser's repeat rate), it's the safest thing to do when dealing with international keyboards,
|
||||||
|
* because our mapping tables are designed for US keyboards, and testing all the permutations of international
|
||||||
|
* keyboards and web browsers is more work than I can take on right now. TODO: Dig into this some day.
|
||||||
|
*/
|
||||||
|
Keyboard.ALL_ONDOWN = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alphanumeric and other common (printable) ASCII codes.
|
* Alphanumeric and other common (printable) ASCII codes.
|
||||||
*
|
*
|
||||||
|
|
@ -2030,25 +2039,18 @@ Keyboard.prototype.onKeyDown = function(event, fDown)
|
||||||
* When I have defined system-wide CTRL-key sequences to perform common editing operations (eg, CTRL_W
|
* When I have defined system-wide CTRL-key sequences to perform common editing operations (eg, CTRL_W
|
||||||
* and CTRL_Z to scroll pages of text), the browser likes to act on those operations, so let's set fPass
|
* and CTRL_Z to scroll pages of text), the browser likes to act on those operations, so let's set fPass
|
||||||
* to false to prevent that.
|
* to false to prevent that.
|
||||||
|
*
|
||||||
|
* Also, we don't want to set fIgnore in such cases, because the browser may not give us a press event for
|
||||||
|
* these CTRL-key sequences, so we can't risk ignoring them.
|
||||||
*/
|
*/
|
||||||
if (Keyboard.SIMCODES[simCode] && (this.bitsState & (Keyboard.STATE.CTRLS | Keyboard.STATE.ALTS))) {
|
if (Keyboard.SIMCODES[simCode] && (this.bitsState & (Keyboard.STATE.CTRLS | Keyboard.STATE.ALTS))) {
|
||||||
fPass = false;
|
fPass = false;
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* HACK: For all other keys (ie, keys not marked as ONDOWN, and non-CTRL/non-ALT combinations), we're
|
|
||||||
* going to ignore their down/up events; even though that prevents those keys from being repeated properly
|
|
||||||
* (ie, at the simulation's repeat rate rather than the browser's repeat rate), it's the safest thing to
|
|
||||||
* do when dealing with international keyboards, because our mapping tables are designed for US keyboards,
|
|
||||||
* and testing all the permutations of international keyboards and browsers is more work than I can take
|
|
||||||
* on now. TODO: Dig into this some day.
|
|
||||||
*/
|
|
||||||
fIgnore = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For now, we also don't want to simulate any key sequence that has the CMD key associated with it.
|
* Don't simulate any key not explicitly marked ONDOWN, as well as any key sequence with the CMD key held.
|
||||||
*/
|
*/
|
||||||
if (!!(this.bitsState & Keyboard.STATE.CMDS)) fIgnore = true;
|
if (!Keyboard.ALL_ONDOWN && fPass && fDown || !!(this.bitsState & Keyboard.STATE.CMDS)) fIgnore = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fPass) {
|
if (!fPass) {
|
||||||
|
|
@ -2065,8 +2067,7 @@ Keyboard.prototype.onKeyDown = function(event, fDown)
|
||||||
* rapid (ie, fake) "up" and "down" events around "press" events, probably more to satisfy compatibility
|
* rapid (ie, fake) "up" and "down" events around "press" events, probably more to satisfy compatibility
|
||||||
* issues rather than making a serious effort to indicate when a key ACTUALLY went down or up.
|
* issues rather than making a serious effort to indicate when a key ACTUALLY went down or up.
|
||||||
*/
|
*/
|
||||||
if (!fIgnore) {
|
if (!fIgnore && (!this.fMobile || !fPass)) {
|
||||||
if (!this.fMobile || !fPass) {
|
|
||||||
if (fDown) {
|
if (fDown) {
|
||||||
this.addActiveKey(simCode, fPress);
|
this.addActiveKey(simCode, fPress);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -2076,7 +2077,6 @@ Keyboard.prototype.onKeyDown = function(event, fDown)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return fPass;
|
return fPass;
|
||||||
};
|
};
|
||||||
|
|
@ -2093,6 +2093,7 @@ Keyboard.prototype.onKeyPress = function(event)
|
||||||
event = event || window.event;
|
event = event || window.event;
|
||||||
var keyCode = event.which || event.keyCode;
|
var keyCode = event.which || event.keyCode;
|
||||||
|
|
||||||
|
if (Keyboard.ALL_ONDOWN) {
|
||||||
var simCode = this.checkActiveKey();
|
var simCode = this.checkActiveKey();
|
||||||
if (simCode && this.isAlphaKey(simCode) && this.isAlphaKey(keyCode) && simCode != keyCode) {
|
if (simCode && this.isAlphaKey(simCode) && this.isAlphaKey(keyCode) && simCode != keyCode) {
|
||||||
if (!COMPILED && this.messageEnabled(Messages.KEYS)) {
|
if (!COMPILED && this.messageEnabled(Messages.KEYS)) {
|
||||||
|
|
@ -2101,6 +2102,7 @@ Keyboard.prototype.onKeyPress = function(event)
|
||||||
this.fToggleCapsLock = true;
|
this.fToggleCapsLock = true;
|
||||||
keyCode = simCode;
|
keyCode = simCode;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Let's stop any injection currently in progress, too
|
* Let's stop any injection currently in progress, too
|
||||||
|
|
@ -2167,17 +2169,17 @@ Keyboard.prototype.keySimulate = function(simCode, fDown)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (bScan == Keyboard.SCANCODE.SHIFT) {
|
if (bScan == Keyboard.SCANCODE.SHIFT) {
|
||||||
if (!(this.bitsState & (Keyboard.STATE.SHIFT | Keyboard.STATE.RSHIFT))) {
|
if (!(this.bitsStateSim & (Keyboard.STATE.SHIFT | Keyboard.STATE.RSHIFT))) {
|
||||||
if (!(this.bitsState & Keyboard.STATE.CAPS_LOCK) || !fAlpha) {
|
if (!(this.bitsStateSim & Keyboard.STATE.CAPS_LOCK) || !fAlpha) {
|
||||||
bShift = bScan;
|
bShift = bScan;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (bScan == Keyboard.SCANCODE.CTRL) {
|
} else if (bScan == Keyboard.SCANCODE.CTRL) {
|
||||||
if (!(this.bitsState & (Keyboard.STATE.CTRL | Keyboard.STATE.RCTRL))) {
|
if (!(this.bitsStateSim & (Keyboard.STATE.CTRL | Keyboard.STATE.RCTRL))) {
|
||||||
bShift = bScan;
|
bShift = bScan;
|
||||||
}
|
}
|
||||||
} else if (bScan == Keyboard.SCANCODE.ALT) {
|
} else if (bScan == Keyboard.SCANCODE.ALT) {
|
||||||
if (!(this.bitsState & (Keyboard.STATE.ALT | Keyboard.STATE.RALT))) {
|
if (!(this.bitsStateSim & (Keyboard.STATE.ALT | Keyboard.STATE.RALT))) {
|
||||||
bShift = bScan;
|
bShift = bScan;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue