Key
constKey:object
Defined in: client/api.d.ts:4992
Client-only, resource-owned physical key bindings exposed as the global Key.
Type Declaration
Section titled “Type Declaration”bind()
Section titled “bind()”bind(
key,stateOrHandler,handler?):boolean
Binds a resource-owned handler that fires while the game has foreground input and no UI is capturing it.
Parameters
Section titled “Parameters”string
Case-insensitive supported keyboard or mouse key name.
stateOrHandler
Section titled “stateOrHandler”"down" | "up" | "both" | KeyHandler
Trigger state, or the handler itself to use the default down state.
handler?
Section titled “handler?”Handler required when an explicit trigger state is provided.
Returns
Section titled “Returns”boolean
True after the binding is installed; invalid keys or states throw.
getLabel()
Section titled “getLabel()”getLabel(
key):string
Returns the current layout’s label for a physical key, even while UI owns input. Query again when refreshing prompts. Throws for unknown keys or non-string arguments.
Parameters
Section titled “Parameters”string
Case-insensitive physical key name, using the same names as bind.
Returns
Section titled “Returns”string
Uppercase printable text, or an English name such as Enter or Mouse 1. Falls back to the uppercase canonical key name when translation is unavailable.
isDown()
Section titled “isDown()”isDown(
key):boolean
Queries live physical key state using the same foreground and UI-input gate as binding dispatch.
Parameters
Section titled “Parameters”string
Case-insensitive supported key name.
Returns
Section titled “Returns”boolean
False when the key is up, the game is backgrounded, UI owns input, or the key name is invalid.
unbind()
Section titled “unbind()”unbind(
key,state?,handler?):boolean
Removes matching bindings owned by the calling resource; omitting filters removes every binding for the key.
Parameters
Section titled “Parameters”string
Case-insensitive supported key name.
state?
Section titled “state?”"down" | "up" | "both"
Optional trigger-state filter.
handler?
Section titled “handler?”Optional exact handler filter.
Returns
Section titled “Returns”boolean
True when at least one binding was removed.