From dc62788d8655862eade5d110c0d316bad9c14da5 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 23 Apr 2014 19:28:18 -0700 Subject: [PATCH] GUAC-644: Fix regression in handling of browser key repeat. --- .../src/main/webapp/modules/Keyboard.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/guacamole-common-js/src/main/webapp/modules/Keyboard.js b/guacamole-common-js/src/main/webapp/modules/Keyboard.js index 7ca539e6e..edc62f5c5 100644 --- a/guacamole-common-js/src/main/webapp/modules/Keyboard.js +++ b/guacamole-common-js/src/main/webapp/modules/Keyboard.js @@ -254,6 +254,14 @@ Guacamole.Keyboard = function(element) { */ this.pressed = {}; + /** + * The last result of calling the onkeydown handler for each key, indexed + * by keysym. This is used to prevent/allow default actions for key events, + * even when the onkeydown handler cannot be called again because the key + * is (theoretically) still pressed. + */ + var last_keydown_result = {}; + /** * The keysym associated with a given keycode when keydown fired. * @private @@ -383,6 +391,7 @@ Guacamole.Keyboard = function(element) { // Send key event if (guac_keyboard.onkeydown) { var result = guac_keyboard.onkeydown(keysym); + last_keydown_result[keysym] = result; // Stop any current repeat window.clearTimeout(key_repeat_timeout); @@ -401,7 +410,8 @@ Guacamole.Keyboard = function(element) { } } - return true; + // Return the last keydown result by default, resort to false if unknown + return last_keydown_result[keysym] || false; }