Skip to content
KCKingdoms Connected Scripting APIScripting guides and API
Global objectClient APIGenerated

Key

const Key: object

Defined in: client/api.d.ts:4992

Client-only, resource-owned physical key bindings exposed as the global Key.

bind(key, stateOrHandler, handler?): boolean

Binds a resource-owned handler that fires while the game has foreground input and no UI is capturing it.

string

Case-insensitive supported keyboard or mouse key name.

"down" | "up" | "both" | KeyHandler

Trigger state, or the handler itself to use the default down state.

KeyHandler

Handler required when an explicit trigger state is provided.

boolean

True after the binding is installed; invalid keys or states throw.

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.

string

Case-insensitive physical key name, using the same names as bind.

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(key): boolean

Queries live physical key state using the same foreground and UI-input gate as binding dispatch.

string

Case-insensitive supported key name.

boolean

False when the key is up, the game is backgrounded, UI owns input, or the key name is invalid.

unbind(key, state?, handler?): boolean

Removes matching bindings owned by the calling resource; omitting filters removes every binding for the key.

string

Case-insensitive supported key name.

"down" | "up" | "both"

Optional trigger-state filter.

KeyHandler

Optional exact handler filter.

boolean

True when at least one binding was removed.