Private
accessThe 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.
Private
focusThe currently focused root. New keyboard events will go to this root
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
keysA set containing the keys currently down.
Check 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.
Private
dispatchDispatches an event to the currently focused root (or a fallback). Handles wrap-around for tab selection. Internal use only.
The event to dispatch
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
Private
getGet the index of a group in the groups list. For internal use only
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.
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.
Hook called by Root#preLayoutUpdate
A generic keyboard driver.
Does nothing on its own, but provides an API for sending keyboard events to registered roots.