Skip to content

Commit a020ef0

Browse files
committed
Merge branch 'altgr-seq-interrupt' of https://github.com/leedagee/noVNC
2 parents 1b2fe33 + 6c07136 commit a020ef0

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

core/input/keyboard.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export default class Keyboard {
203203
if ((code === "ControlLeft") && browser.isWindows() &&
204204
!("ControlLeft" in this._keyDownList)) {
205205
this._altGrArmed = true;
206-
this._altGrTimeout = setTimeout(this._handleAltGrTimeout.bind(this), 100);
206+
this._altGrTimeout = setTimeout(this._interruptAltGrSequence.bind(this), 100);
207207
this._altGrCtrlTime = e.timeStamp;
208208
return;
209209
}
@@ -218,11 +218,7 @@ export default class Keyboard {
218218

219219
// We can't get a release in the middle of an AltGr sequence, so
220220
// abort that detection
221-
if (this._altGrArmed) {
222-
this._altGrArmed = false;
223-
clearTimeout(this._altGrTimeout);
224-
this._sendKeyEvent(KeyTable.XK_Control_L, "ControlLeft", true);
225-
}
221+
this._interruptAltGrSequence();
226222

227223
// See comment in _handleKeyDown()
228224
if ((browser.isMac() || browser.isIOS()) && (code === 'CapsLock')) {
@@ -249,14 +245,20 @@ export default class Keyboard {
249245
}
250246
}
251247

252-
_handleAltGrTimeout() {
253-
this._altGrArmed = false;
254-
clearTimeout(this._altGrTimeout);
255-
this._sendKeyEvent(KeyTable.XK_Control_L, "ControlLeft", true);
248+
_interruptAltGrSequence() {
249+
if (this._altGrArmed) {
250+
this._altGrArmed = false;
251+
clearTimeout(this._altGrTimeout);
252+
this._sendKeyEvent(KeyTable.XK_Control_L, "ControlLeft", true);
253+
}
256254
}
257255

258256
_allKeysUp() {
259257
Log.Debug(">> Keyboard.allKeysUp");
258+
259+
// Prevent control key being processed after losing focus.
260+
this._interruptAltGrSequence();
261+
260262
for (let code in this._keyDownList) {
261263
this._sendKeyEvent(this._keyDownList[code], code, false);
262264
}

0 commit comments

Comments
 (0)