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

modifiers

All modifiers and their states.
Source:

pressed

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.
Source:

Methods

listenTo(element)

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(str)

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(keysym) → {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(e) → {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: