From b6769e4ba0d33fbcd6f4e8673078661636632403 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 29 Sep 2014 02:03:32 -0700 Subject: [PATCH] GUAC-391: Add *gag* detection of OS *gag* because there's no other way *gag* to know if it's safe to wait for keypress while Alt is held when keydown is not accurate enough *vomits*. --- .../src/main/webapp/modules/Keyboard.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/guacamole-common-js/src/main/webapp/modules/Keyboard.js b/guacamole-common-js/src/main/webapp/modules/Keyboard.js index 8ba10c56f..1ce3da1bd 100644 --- a/guacamole-common-js/src/main/webapp/modules/Keyboard.js +++ b/guacamole-common-js/src/main/webapp/modules/Keyboard.js @@ -186,10 +186,17 @@ Guacamole.Keyboard = function(element) { if (!this.keysym && key_identifier_sane(keyCode, keyIdentifier)) this.keysym = keysym_from_key_identifier(keyIdentifier, location, guac_keyboard.modifiers.shift); + // Determine whether default action for Alt+combinations must be prevented + var prevent_alt = !guac_keyboard.modifiers.ctrl + && !(navigator && navigator.platform && navigator.platform.match(/^mac/i)); + + // Determine whether default action for Ctrl+combinations must be prevented + var prevent_ctrl = !guac_keyboard.modifiers.alt; + // We must rely on the (potentially buggy) keyIdentifier if preventing // the default action is important - if ((guac_keyboard.modifiers.ctrl && !guac_keyboard.modifiers.alt) - || (guac_keyboard.modifiers.alt && !guac_keyboard.modifiers.ctrl) + if ((prevent_ctrl && guac_keyboard.modifiers.ctrl) + || (prevent_alt && guac_keyboard.modifiers.alt) || guac_keyboard.modifiers.meta || guac_keyboard.modifiers.hyper) this.reliable = true;