Protected
Readonly
groupA map from a Root to a group. Used only for optimisation purposes. Do not modify from a child class.
Protected
Readonly
groupsGroups belonging to this driver. Roots in the same group transfer tab selections between themselves. Do not modify from a child class.
Private
tabCheck if the currently focused root needs keyboard input. Virtual keyboard should query this property to know when to show themselves.
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.
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.
Returns the created group. The group is live, do not modify it directly.
Protected
changeChanges the current root focus.
If there was a previous root focus, that root's Root#clearFocus is called with FocusType#Keyboard.
KeyboardDriver#keysDown is cleared.
Clear the current root focus. Calls KeyboardDriver#changeFocusedRoot with null.
Get a new group, with no Roots.
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).
Similar to KeyboardDriver#getFocusedRoot, but can fall back to the first root of KeyboardDriver#accessList if KeyboardDriver#focus is null.
Get the current root focus.
Returns KeyboardDriver#focus
Get the group that a Root is assigned to. Throws an error if the Root is not assigned to any group in this driver.
Returns the group assigned to this Root. The group is live, do not modify it directly.
Check if a key is pressed.
Must follow the KeyboardEvent.key Web API.
Returns true if key was in KeyboardDriver#keysDown
Dispatch a new KeyPressEvent event to the effective focused Root.
Must follow the KeyboardEvent.key Web API.
Is shift being pressed?
Is control being pressed?
Is alt being pressed?
Is the key down originating from a virtual keyboard? False by default
Returns a list of dispatched events and whether they were captured.
Calls KeyboardDriver#keyDown followed by KeyboardDriver#keyUp. If the key was already down before calling (KeyboardDriver#isKeyDown), keyUp is not called.
Must follow the KeyboardEvent.key Web API.
Is shift being pressed?
Is control being pressed?
Is alt being pressed?
Is the key press originating from a virtual keyboard? False by default
Returns a list of dispatched events and whether they were captured.
Dispatch a new KeyReleaseEvent event to the effective focused Root.
Must follow the KeyboardEvent.key Web API.
Is shift being pressed?
Is control being pressed?
Is alt being pressed?
Is the key up originating from a virtual keyboard? False by default
Returns a list of dispatched events and whether they were captured.
Calls preventDefault and stopImmediatePropagation on a keyboard event if needed.
List of events that were maybe captured by a Root
The keyboard event that can be preventDefault'ed/stopImmediatePropagation'ed
Removes disabled root from KeyboardDriver#accessList and its respective group. If the root was the KeyboardDriver#focus, then the focus is cleared.
Adds enabled root to KeyboardDriver#accessList and its respective group.
Hook called by Root#dispatchEvent
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.
Check if the root focus should be cleared given that the HTML DOM focus has been lost to another HTML DOM element
The HTML DOM element to which the focus has been lost to
Hook called by Root#preLayoutUpdate
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.