The set of key codes which are currently depressed (down)
The set of movement keys which were recently pressed
Static
CONTROL_The OS-specific string display for what their Command key is
Static
KEYCODE_A 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.
Static
MODIFIER_Track which KeyboardEvent#code presses associate with each modifier.
Static
MODIFIER_Allowed modifier keys.
Static
PRINTABLE_Matches any single graphic Unicode code-point (letters, digits, punctuation, symbols, including emoji). Non-printable identifiers like ArrowLeft, ShiftLeft, Dead never match.
Static
PROTECTED_Key codes which are "protected" and should not be used because they are reserved for browser-level actions.
Determines whether an HTMLElement
currently has focus, which may influence keybinding actions.
An element is considered to have focus if:
dataset.keyboardFocus
attribute explicitly set to "true"
or an empty string (""
).<input>
, <select>
, or <textarea>
element, all of which inherently accept keyboard input.isContentEditable
property set to true
, meaning it is an editable element.<button>
element inside a <form>
, which suggests interactive use.An element is considered not focused if:
document.activeElement
is not an HTMLElement
).dataset.keyboardFocus
attribute explicitly set to "false"
.If none of these conditions are met, the element is assumed to be unfocused.
Static
isIs logical keybindings active?
Internal
Begin listening to keyboard events.
Report whether a core action key is currently actively depressed.
The core action to verify (ex: "target")
Is this core action key currently down (active)?
Report whether a modifier in KeyboardManager.MODIFIER_KEYS is currently actively depressed.
A modifier in MODIFIER_KEYS
Is this modifier key currently down (active)?
Emulate a key-up event for any currently down keys. When emulating, we go backwards such that combinations such as "CONTROL + S" emulate the "S" first in order to capture modifiers.
Optional
options: { force?: boolean } = {}Options to configure behavior.
Optional
force?: booleanForce the keyup events to be handled.
Protected
_onProtected
Release any down keys when focusing a form element.
The focus event.
Protected
_processProtected
Processes a keyboard event context, checking it against registered keybinding actions
The keyboard event context
Optional
options: { force?: boolean } = {}Additional options to configure behavior.
Optional
force?: booleanForce the event to be handled.
Static
_getInternal
Given a keyboard-event context, return every registered keybinding that matches it (may be empty).
Static
emulateEmulates a key being pressed, triggering the Keyboard event workflow.
If True, emulates the keyup
Event. Else, the keydown
event
The KeyboardEvent#code which is being pressed
Optional
options: {Additional options to configure behavior.
Optional
altKey?: booleanEmulate the ALT modifier as pressed
Optional
ctrlKey?: booleanEmulate the CONTROL modifier as pressed
Optional
force?: booleanForce the event to be handled.
Optional
repeat?: booleanEmulate this as a repeat event
Optional
shiftKey?: booleanEmulate the SHIFT modifier as pressed
Static
getGet 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
The originating keypress event
A flag for whether the key is down or up
The standardized context of the event
Static
getFormat a KeyboardEvent#code into a displayed string.
The input code
The displayed string for this code
Static
translateCanonical identifier for a key press.
A set of helpers and management functions for dealing with user input from keyboard events. https://keycode.info/
See
foundry.Game#keyboard