From: Michael Jumper Date: Wed, 16 May 2012 20:36:28 +0000 (-0700) Subject: As keydown/keypress are handled via deferred setTimeout(), so should keyup (otherwise... X-Git-Url: http://git.alex.org.uk As keydown/keypress are handled via deferred setTimeout(), so should keyup (otherwise, there's a race condition that keyup might happen before the deferred handling of keydown/keypress, and the key might be effectively stuck down or in a repeating state). --- diff --git a/src/main/resources/keyboard.js b/src/main/resources/keyboard.js index af19c26..4f95716 100644 --- a/src/main/resources/keyboard.js +++ b/src/main/resources/keyboard.js @@ -511,21 +511,27 @@ Guacamole.Keyboard = function(element) { if (window.event) keynum = window.event.keyCode; else if (e.which) keynum = e.which; - // Ctrl/Alt/Shift - if (keynum == 16) guac_keyboard.modifiers.shift = false; - else if (keynum == 17) guac_keyboard.modifiers.ctrl = false; - else if (keynum == 18) guac_keyboard.modifiers.alt = false; - else - stopRepeat(); + // Defer handling of keyup (otherwise, keyup may happen before + // deferred handling of keydown/keypress). + window.setTimeout(function() { + + // Ctrl/Alt/Shift + if (keynum == 16) guac_keyboard.modifiers.shift = false; + else if (keynum == 17) guac_keyboard.modifiers.ctrl = false; + else if (keynum == 18) guac_keyboard.modifiers.alt = false; + else + stopRepeat(); + + // Get corresponding character + var lastKeyDownChar = keydownChar[keynum]; - // Get corresponding character - var lastKeyDownChar = keydownChar[keynum]; + // Clear character record + keydownChar[keynum] = null; - // Clear character record - keydownChar[keynum] = null; + // Send release event + sendKeyReleased(lastKeyDownChar); - // Send release event - sendKeyReleased(lastKeyDownChar); + }, 0); };