mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
Track pressed status of keys. Only release/press keys if not already in that status.
This commit is contained in:
@@ -269,47 +269,65 @@ Guacamole.OnScreenKeyboard = function(url) {
|
|||||||
key_element.onmousedown =
|
key_element.onmousedown =
|
||||||
key_element.ontouchstart = function() {
|
key_element.ontouchstart = function() {
|
||||||
|
|
||||||
key_element.classList.add("guac-keyboard-pressed");
|
// Press key if not yet pressed
|
||||||
|
if (!key.pressed) {
|
||||||
|
|
||||||
// Get current cap based on modifier state
|
key_element.classList.add("guac-keyboard-pressed");
|
||||||
var cap = key.getCap(on_screen_keyboard.modifiers);
|
|
||||||
|
|
||||||
// Update modifier state
|
// Get current cap based on modifier state
|
||||||
if (cap.modifier) {
|
var cap = key.getCap(on_screen_keyboard.modifiers);
|
||||||
|
|
||||||
// Construct classname for modifier
|
// Update modifier state
|
||||||
var modifierClass = "guac-keyboard-modifier-" + cap.modifier;
|
if (cap.modifier) {
|
||||||
var modifierFlag = getModifier(cap.modifier);
|
|
||||||
|
|
||||||
// Toggle modifier state
|
// Construct classname for modifier
|
||||||
on_screen_keyboard.modifiers ^= modifierFlag;
|
var modifierClass = "guac-keyboard-modifier-" + cap.modifier;
|
||||||
|
var modifierFlag = getModifier(cap.modifier);
|
||||||
|
|
||||||
// Activate modifier if pressed
|
// Toggle modifier state
|
||||||
if (on_screen_keyboard.modifiers & modifierFlag)
|
on_screen_keyboard.modifiers ^= modifierFlag;
|
||||||
keyboard.classList.add(modifierClass);
|
|
||||||
|
|
||||||
// Deactivate if not pressed
|
// Activate modifier if pressed
|
||||||
else
|
if (on_screen_keyboard.modifiers & modifierFlag)
|
||||||
keyboard.classList.remove(modifierClass);
|
keyboard.classList.add(modifierClass);
|
||||||
|
|
||||||
|
// Deactivate if not pressed
|
||||||
|
else
|
||||||
|
keyboard.classList.remove(modifierClass);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send key event
|
||||||
|
if (on_screen_keyboard.onkeydown && cap.keysym)
|
||||||
|
on_screen_keyboard.onkeydown(cap.keysym);
|
||||||
|
|
||||||
|
// Mark key as pressed
|
||||||
|
key.pressed = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (on_screen_keyboard.onkeydown && cap.keysym)
|
|
||||||
on_screen_keyboard.onkeydown(cap.keysym);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
key_element.onmouseup =
|
key_element.onmouseup =
|
||||||
key_element.onmouseout =
|
key_element.onmouseout =
|
||||||
key_element.ontouchend = function() {
|
key_element.ontouchend = function() {
|
||||||
|
|
||||||
// Get current cap based on modifier state
|
// Release key if currently pressed
|
||||||
var cap = key.getCap(on_screen_keyboard.modifiers);
|
if (key.pressed) {
|
||||||
|
|
||||||
key_element.classList.remove("guac-keyboard-pressed");
|
// Get current cap based on modifier state
|
||||||
|
var cap = key.getCap(on_screen_keyboard.modifiers);
|
||||||
|
|
||||||
if (on_screen_keyboard.onkeyup && cap.keysym)
|
key_element.classList.remove("guac-keyboard-pressed");
|
||||||
on_screen_keyboard.onkeyup(cap.keysym);
|
|
||||||
|
// Send key event
|
||||||
|
if (on_screen_keyboard.onkeyup && cap.keysym)
|
||||||
|
on_screen_keyboard.onkeyup(cap.keysym);
|
||||||
|
|
||||||
|
// Mark key as released
|
||||||
|
key.pressed = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -409,6 +427,11 @@ Guacamole.OnScreenKeyboard.Key = function() {
|
|||||||
|
|
||||||
var key = this;
|
var key = this;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this key is currently pressed.
|
||||||
|
*/
|
||||||
|
this.pressed = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Width of the key, relative to the size of the keyboard.
|
* Width of the key, relative to the size of the keyboard.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user