GUACAMOLE-1823: Update unreliable capslock keyup event semantic since now it also covers keydown event.

This commit is contained in:
Miroslav Šedivý committed 2023-07-12 22:45:56 +02:00
1 parent d42bdd33be
commit 545bc275de
1 file changed
+8 -7
@@ -109,12 +109,12 @@ Guacamole.Keyboard = function Keyboard(element) {
altIsTypableOnly: false, altIsTypableOnly: false,
/** /**
* Whether we can rely on receiving a keyup event for the Caps Lock * Whether we can rely on receiving a keyup or keydown event for the
* key. * Caps Lock key.
* *
* @type {!boolean} * @type {!boolean}
*/ */
capsLockKeyupUnreliable: false capsLockKeyEventUnreliable: false
}; };
@@ -127,10 +127,11 @@ Guacamole.Keyboard = function Keyboard(element) {
quirks.keyupUnreliable = true; quirks.keyupUnreliable = true;
// The Alt key on Mac is never used for keyboard shortcuts, and the // 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)) { else if (navigator.platform.match(/^mac/i)) {
quirks.altIsTypableOnly = true; quirks.altIsTypableOnly = true;
quirks.capsLockKeyupUnreliable = true; quirks.capsLockKeyEventUnreliable = true;
} }
} }
@@ -289,7 +290,7 @@ Guacamole.Keyboard = function Keyboard(element) {
this.keyupReliable = false; this.keyupReliable = false;
// We cannot rely on receiving keyup for Caps Lock on certain platforms // 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; this.keyupReliable = false;
// Determine whether default action for Alt+combinations must be prevented // 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 // 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 // we need to pretend that this is a keydown event because we obviously
// did not receive it (issue on macos with chrome) // 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)); eventLog.push(new KeydownEvent(this));
return; return;
} }