mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
Allow default action of key events to be manually enabled.
This commit is contained in:
@@ -44,6 +44,8 @@ Guacamole.Keyboard = function(element) {
|
|||||||
*
|
*
|
||||||
* @event
|
* @event
|
||||||
* @param {Number} keysym The keysym of the key being pressed.
|
* @param {Number} keysym The keysym of the key being pressed.
|
||||||
|
* @return {Boolean} true if the key event should be allowed through to the
|
||||||
|
* browser, false otherwise.
|
||||||
*/
|
*/
|
||||||
this.onkeydown = null;
|
this.onkeydown = null;
|
||||||
|
|
||||||
@@ -365,6 +367,7 @@ Guacamole.Keyboard = function(element) {
|
|||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param keysym The keysym of the key to press.
|
* @param keysym The keysym of the key to press.
|
||||||
|
* @return {Boolean} true if event should NOT be canceled, false otherwise.
|
||||||
*/
|
*/
|
||||||
function press_key(keysym) {
|
function press_key(keysym) {
|
||||||
|
|
||||||
@@ -379,7 +382,7 @@ Guacamole.Keyboard = function(element) {
|
|||||||
|
|
||||||
// Send key event
|
// Send key event
|
||||||
if (guac_keyboard.onkeydown) {
|
if (guac_keyboard.onkeydown) {
|
||||||
guac_keyboard.onkeydown(keysym);
|
var result = guac_keyboard.onkeydown(keysym);
|
||||||
|
|
||||||
// Stop any current repeat
|
// Stop any current repeat
|
||||||
window.clearTimeout(key_repeat_timeout);
|
window.clearTimeout(key_repeat_timeout);
|
||||||
@@ -394,9 +397,12 @@ Guacamole.Keyboard = function(element) {
|
|||||||
}, 50);
|
}, 50);
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -519,9 +525,9 @@ Guacamole.Keyboard = function(element) {
|
|||||||
// Press key if known
|
// Press key if known
|
||||||
if (keysym !== null) {
|
if (keysym !== null) {
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
keydownChar[keynum] = keysym;
|
keydownChar[keynum] = keysym;
|
||||||
press_key(keysym);
|
if (!press_key(keysym))
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
// If a key is pressed while meta is held down, the keyup will
|
// If a key is pressed while meta is held down, the keyup will
|
||||||
// never be sent in Chrome, so send it now. (bug #108404)
|
// never be sent in Chrome, so send it now. (bug #108404)
|
||||||
@@ -538,8 +544,6 @@ Guacamole.Keyboard = function(element) {
|
|||||||
// Only intercept if handler set
|
// Only intercept if handler set
|
||||||
if (!guac_keyboard.onkeydown && !guac_keyboard.onkeyup) return;
|
if (!guac_keyboard.onkeydown && !guac_keyboard.onkeyup) return;
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
var keynum;
|
var keynum;
|
||||||
if (window.event) keynum = window.event.keyCode;
|
if (window.event) keynum = window.event.keyCode;
|
||||||
else if (e.which) keynum = e.which;
|
else if (e.which) keynum = e.which;
|
||||||
@@ -560,9 +564,12 @@ Guacamole.Keyboard = function(element) {
|
|||||||
|
|
||||||
// Send press + release if keysym known
|
// Send press + release if keysym known
|
||||||
if (keysym !== null) {
|
if (keysym !== null) {
|
||||||
press_key(keysym);
|
if (!press_key(keysym))
|
||||||
|
e.preventDefault();
|
||||||
release_key(keysym);
|
release_key(keysym);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user