GUACAMOLE-1823: Merge changes addressing unreliable capslock behavior under MacOS Chrome.

This commit is contained in:
Mike Jumper authored and GitHub committed 2025-09-13 09:31:17 -07:00
commit 3b7473d114
1 file changed
+15 -6
@@ -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
@@ -359,6 +360,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.capsLockKeyEventUnreliable) {
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)