Constructor
new KeyboardManager()
Members
CONTROL_KEY_STRING :string
The OS-specific string display for what their Command key is
Type:
- string
downKeys :Set.<string>
The set of key codes which are currently depressed (down)
Type:
- Set.<string>
hasFocus
Test whether a Form Element currently has focus
KEYCODE_DISPLAY_MAPPING :Object.<string, string>
An special mapping of how special KeyboardEvent#code values should map to displayed strings or symbols. Values in this configuration object override any other display formatting rules which may be applied.
Type:
- Object.<string, string>
MODIFIER_CODES :Array.<string>
Track which KeyboardEvent#code presses associate with each modifier
Type:
- Array.<string>
MODIFIER_KEYS :string
Allowed modifier keys
Type:
- string
moveKeys :Set.<string>
The set of movement keys which were recently pressed
Type:
- Set.<string>
PROTECTED_KEYS :Array.<string>
Key codes which are "protected" and should not be used because they are reserved for browser-level actions.
Type:
- Array.<string>
Methods
(package, static) _getMatchingActions(context) → {Array.<KeybindingAction>}
Given a standardized pressed key, find all matching registered Keybind Actions.
Parameters:
Name | Type | Description |
---|---|---|
context |
KeyboardEventContext | A standardized keyboard event context |
Returns:
The matched Keybind Actions. May be empty.
- Type
- Array.<KeybindingAction>
(static) emulateKeypress(up, code, altKey, ctrlKey, shiftKey, repeat) → {KeyboardEventContext}
Emulates a key being pressed, triggering the Keyboard event workflow.
Parameters:
Name | Type | Description |
---|---|---|
up |
boolean | If True, emulates the |
code |
string | The KeyboardEvent#code which is being pressed |
altKey |
boolean | Emulate the ALT modifier as pressed |
ctrlKey |
boolean | Emulate the CONTROL modifier as pressed |
shiftKey |
boolean | Emulate the SHIFT modifier as pressed |
repeat |
boolean | Emulate this as a repeat event |
Returns:
- Type
- KeyboardEventContext
(static) getKeyboardEventContext(event, up) → {KeyboardEventContext}
Get a standardized keyboard context for a given event. Every individual keypress is uniquely identified using the KeyboardEvent#code property. A list of possible key codes is documented here: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code/code_values
Parameters:
Name | Type | Default | Description |
---|---|---|---|
event |
KeyboardEvent | The originating keypress event |
|
up |
boolean |
false
|
A flag for whether the key is down or up |
Returns:
The standardized context of the event
- Type
- KeyboardEventContext
(static) getKeycodeDisplayString(code) → {string}
Format a KeyboardEvent#code into a displayed string.
Parameters:
Name | Type | Description |
---|---|---|
code |
string | The input code |
Returns:
The displayed string for this code
- Type
- string
_onCompositionEnd(event)
Input events do not fire with isComposing = false at the end of a composition event in Chrome See: https://github.com/w3c/uievents/issues/202
Parameters:
Name | Type | Description |
---|---|---|
event |
CompositionEvent |
isModifierActive(modifier) → {boolean}
Report whether a modifier in KeyboardManager.MODIFIER_KEYS is currently actively depressed.
Parameters:
Name | Type | Description |
---|---|---|
modifier |
string | A modifier in MODIFIER_KEYS |
Returns:
Is this modifier key currently down (active)?
- Type
- boolean