Class DOMKeyboardDriver

A KeyboardDriver which listens for key events from HTML DOM elements.

Note that if a DOM element is unfocused in the DOM to an unbound DOM element, the root focus is cleared. If this creates issues, other DOM elements can be bound without listening for key events.

Hierarchy (view full)

Constructors

Properties

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

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

groups: DOMKeyboardDriverGroup[] = ...

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

tabKeyHelper: TabKeyHelper

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

  • Calls preventDefault and stopImmediatePropagation on a keyboard event if needed.

    Parameters

    • captureList: CaptureList

      List of events that were maybe captured by a Root

    • event: KeyboardEvent

      The keyboard event that can be preventDefault'ed/stopImmediatePropagation'ed

    Returns void

  • 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

  • Check if the root focus should be cleared given that the HTML DOM focus has been lost to another HTML DOM element

    Parameters

    • newTarget: null | HTMLElement

      The HTML DOM element to which the focus has been lost to

    Returns boolean