GUACAMOLE-232: Do not rely on receiving keyup events on iOS.

This commit is contained in:
Michael Jumper
2018-01-15 00:22:15 -08:00
parent d84f03afea
commit 960e83f780

View File

@@ -65,6 +65,13 @@ Guacamole.Keyboard = function(element) {
*/ */
var quirks = { var quirks = {
/**
* Whether keyup events are universally unreliable.
*
* @type {Boolean}
*/
keyupUnreliable: false,
/** /**
* Whether the Alt key is actually a modifier for typable keys and is * Whether the Alt key is actually a modifier for typable keys and is
* thus never used for keyboard shortcuts. * thus never used for keyboard shortcuts.
@@ -79,8 +86,12 @@ Guacamole.Keyboard = function(element) {
// available // available
if (navigator && navigator.platform) { if (navigator && navigator.platform) {
// All keyup events are unreliable on iOS (sadly)
if (navigator.platform.match(/ipad|iphone|ipod/i))
quirks.keyupUnreliable = true;
// The Alt key on Mac is never used for keyboard shortcuts // The Alt key on Mac is never used for keyboard shortcuts
if (navigator.platform.match(/^mac/i)) else if (navigator.platform.match(/^mac/i))
quirks.altIsTypableOnly = true; quirks.altIsTypableOnly = true;
} }
@@ -211,7 +222,7 @@ Guacamole.Keyboard = function(element) {
* *
* @type {Boolean} * @type {Boolean}
*/ */
this.keyupReliable = true; this.keyupReliable = !quirks.keyupUnreliable;
// DOM3 and keyCode are reliable sources if the corresponding key is // DOM3 and keyCode are reliable sources if the corresponding key is
// not a printable key // not a printable key
@@ -1021,7 +1032,7 @@ Guacamole.Keyboard = function(element) {
} // end if keydown } // end if keydown
// Keyup event // Keyup event
else if (first instanceof KeyupEvent) { else if (first instanceof KeyupEvent && !quirks.keyupUnreliable) {
// Release specific key if known // Release specific key if known
var keysym = first.keysym; var keysym = first.keysym;