Class: Keyboard

Guacamole.Keyboard(elementopt)

new Keyboard(elementopt)

Provides cross-browser and cross-keyboard keyboard for a specific element. Browser and keyboard layout variation is abstracted away, providing events which represent keys as their corresponding X11 keysym.
Parameters:
Name Type Attributes Description
element Element | Document <optional>
The Element to use to provide keyboard events. If omitted, at least one Element must be manually provided through the listenTo() function for the Guacamole.Keyboard instance to have any effect.
Source:

Classes

ModifierState

Members

(non-null) modifiers :Guacamole.Keyboard.ModifierState

All modifiers and their states.
Type:
Source:

(non-null) pressed :Object.<number, boolean>

The state of every key, indexed by keysym. If a particular key is pressed, the value of pressed for that keysym will be true. If a key is not currently pressed, it will not be defined.
Type:
  • Object.<number, boolean>
Source:

Methods

listenTo(elementnon-null)

Attaches event listeners to the given Element, automatically translating received key, input, and composition events into simple keydown/keyup events signalled through this Guacamole.Keyboard's onkeydown and onkeyup handlers.
Parameters:
Name Type Description
element Element | Document The Element to attach event listeners to for the sake of handling key or input events.
Source:

press(keysym) → {boolean}

Marks a key as pressed, firing the keydown event if registered. Key repeat for the pressed key will start after a delay if that key is not a modifier. The return value of this function depends on the return value of the keydown event handler, if any.
Parameters:
Name Type Description
keysym number The keysym of the key to press.
Source:
Returns:
true if event should NOT be canceled, false otherwise.
Type
boolean

release(keysym)

Marks a key as released, firing the keyup event if registered.
Parameters:
Name Type Description
keysym number The keysym of the key to release.
Source:

reset()

Resets the state of this keyboard, releasing all keys, and firing keyup events for each released key.
Source:

type(strnon-null)

Presses and releases the keys necessary to type the given string of text.
Parameters:
Name Type Description
str string The string to type.
Source:

(inner) isPrintable(keysymnon-null) → (non-null) {boolean}

Returns true if the given keysym corresponds to a printable character, false otherwise.
Parameters:
Name Type Description
keysym number The keysym to check.
Source:
Returns:
true if the given keysym corresponds to a printable character, false otherwise.
Type
boolean

(inner) markEvent(enon-null) → (non-null) {boolean}

Attempts to mark the given Event as having been handled by this Guacamole.Keyboard. If the Event has already been marked as handled, false is returned.
Parameters:
Name Type Description
e Event The Event to mark.
Source:
Returns:
true if the given Event was successfully marked, false if the given Event was already marked.
Type
boolean

Events

onkeydown

Fired whenever the user presses a key with the element associated with this Guacamole.Keyboard in focus.
Parameters:
Name Type Description
keysym number The keysym of the key being pressed.
Source:
Returns:
true if the key event should be allowed through to the browser, false otherwise.
Type
boolean

onkeyup

Fired whenever the user releases a key with the element associated with this Guacamole.Keyboard in focus.
Parameters:
Name Type Description
keysym number The keysym of the key being released.
Source: