Class KeyboardDriver<G, O>

A generic keyboard driver.

Does nothing on its own, but provides an API for sending keyboard events to registered roots.

Type Parameters

Hierarchy (view full)

Implements

Constructors

Properties

accessList: Root[] = ...

The list of Roots that are using this driver, in the order of access; the last focused (with any focus type) Root is moved to the beginning of the list.

Used as a fallback for KeyboardDriver#focus.

focus: null | Root = null

The currently focused root. New keyboard events will go to this root

groupMap: Map<Root, G> = ...

A map from a Root to a group. Used only for optimisation purposes. Do not modify from a child class.

groups: G[] = ...

Groups belonging to this driver. Roots in the same group transfer tab selections between themselves. Do not modify from a child class.

keysDown: Set<string> = ...

A set containing the keys currently down.

Accessors

  • get needsInput(): boolean
  • Check if the currently focused root needs keyboard input. Virtual keyboard should query this property to know when to show themselves.

    Returns boolean

Methods

  • Bind a Root to a group that is assigned to this keyboard. Throws an error if the Root is already assigned to a group in this driver.

    Parameters

    Returns void

  • Bind a Root to this keyboard, in a new group dedicated to the Root. Equivalent to creating a new group and binding a Root to it. Useful if you are using lazy-widgets directly in the DOM, where each Root has a dedicated DOM element.

    Parameters

    Returns G

    Returns the created group. The group is live, do not modify it directly.

  • Delete a group that is assigned to this keyboard. Throws an error if the group is still in use (has assigned Roots).

    Parameters

    • group: G

    Returns void

  • Get the group that a Root is assigned to. Throws an error if the Root is not assigned to any group in this driver.

    Parameters

    Returns G

    Returns the group assigned to this Root. The group is live, do not modify it directly.

  • Get the index of a group in the groups list. For internal use only

    Parameters

    • group: G

    Returns number

  • Does nothing if the new focus type is not a FocusType.Keyboard. If the focus comes from a root which is not the root focus, then the root focus is changed to the new root. If there is no new focused widget (the root's keyboard focus was cleared), then nothing happens.

    If a Root becomes focused (with any focus type, not just keyboard focus), it is moved to the beginning of the KeyboardDriver#accessList list.

    This behaviour is confusing, however, it's required so that the keyboard focus "lingers" for future tab key presses; this way, pressing tab can do tab selection even when there is no widget that wants keyboard input. When a focus is lingering, then it means that key events are still being dispatched to the last focused root, but they don't have a target. This way, most events get dropped, but tab key events are used for tab selection.

    Parameters

    Returns void

  • Unbind a Root from its assigned group. Throws an error if the Root is not assigned to any group in this driver.

    Parameters

    Returns void