From d42bdd33bef4af73e06ecf2e729340fc76f13820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Wed, 12 Jul 2023 22:41:36 +0200 Subject: [PATCH 1/2] GUACAMOLE-1823: Fix capslock on macos chrome. --- guacamole-common-js/src/main/webapp/modules/Keyboard.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/guacamole-common-js/src/main/webapp/modules/Keyboard.js b/guacamole-common-js/src/main/webapp/modules/Keyboard.js index 748cab3cc..fa507ba19 100644 --- a/guacamole-common-js/src/main/webapp/modules/Keyboard.js +++ b/guacamole-common-js/src/main/webapp/modules/Keyboard.js @@ -355,6 +355,14 @@ Guacamole.Keyboard = function Keyboard(element) { // We extend KeyEvent KeyEvent.call(this, orig); + // If unreliable caps lock was pressed and event was not marked, then + // we need to pretend that this is a keydown event because we obviously + // did not receive it (issue on macos with chrome) + if (this.keyCode == 20 && quirks.capsLockKeyupUnreliable) { + eventLog.push(new KeydownEvent(this)); + return; + } + // If key is known from keyCode or DOM3 alone, use that (keyCode is // still more reliable for keyup when dead keys are in use) this.keysym = keysym_from_keycode(this.keyCode, this.location) From 545bc275de3679c5e159824518943a82ba37404b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Wed, 12 Jul 2023 22:45:56 +0200 Subject: [PATCH 2/2] GUACAMOLE-1823: Update unreliable capslock keyup event semantic since now it also covers keydown event. --- .../src/main/webapp/modules/Keyboard.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/guacamole-common-js/src/main/webapp/modules/Keyboard.js b/guacamole-common-js/src/main/webapp/modules/Keyboard.js index fa507ba19..767f757ed 100644 --- a/guacamole-common-js/src/main/webapp/modules/Keyboard.js +++ b/guacamole-common-js/src/main/webapp/modules/Keyboard.js @@ -109,12 +109,12 @@ Guacamole.Keyboard = function Keyboard(element) { altIsTypableOnly: false, /** - * Whether we can rely on receiving a keyup event for the Caps Lock - * key. + * Whether we can rely on receiving a keyup or keydown event for the + * Caps Lock key. * * @type {!boolean} */ - capsLockKeyupUnreliable: false + capsLockKeyEventUnreliable: false }; @@ -127,10 +127,11 @@ Guacamole.Keyboard = function Keyboard(element) { quirks.keyupUnreliable = true; // The Alt key on Mac is never used for keyboard shortcuts, and the - // Caps Lock key never dispatches keyup events + // Caps Lock key never dispatches keyup events in firefox, and it + // dispatches either keydown or keyup events in chrome, but never both else if (navigator.platform.match(/^mac/i)) { quirks.altIsTypableOnly = true; - quirks.capsLockKeyupUnreliable = true; + quirks.capsLockKeyEventUnreliable = true; } } @@ -289,7 +290,7 @@ Guacamole.Keyboard = function Keyboard(element) { this.keyupReliable = false; // We cannot rely on receiving keyup for Caps Lock on certain platforms - else if (this.keysym === 0xFFE5 && quirks.capsLockKeyupUnreliable) + else if (this.keysym === 0xFFE5 && quirks.capsLockKeyEventUnreliable) this.keyupReliable = false; // Determine whether default action for Alt+combinations must be prevented @@ -358,7 +359,7 @@ Guacamole.Keyboard = function Keyboard(element) { // If unreliable caps lock was pressed and event was not marked, then // we need to pretend that this is a keydown event because we obviously // did not receive it (issue on macos with chrome) - if (this.keyCode == 20 && quirks.capsLockKeyupUnreliable) { + if (this.keyCode == 20 && quirks.capsLockKeyEventUnreliable) { eventLog.push(new KeydownEvent(this)); return; }