Skip to content

Hotkeys Api

GL.hotkeys

Accessors

pressed

Get Signature

get pressed(): Set<string>

Which key codes are currently being pressed

Returns

Set<string>

Methods

addConfigurableHotkey()

addConfigurableHotkey(id, options, callback): () => void

Adds a hotkey which can be changed by the user

Parameters

ParameterTypeDescription
idstringA unique id for the hotkey, such as myplugin-myhotkey
options{ category: string; default: { alt: boolean; ctrl: boolean; key: string; keys: string[]; shift: boolean; }; preventDefault: boolean; title: string; }-
options.categorystring-
options.default?{ alt: boolean; ctrl: boolean; key: string; keys: string[]; shift: boolean; }-
options.default.alt?boolean-
options.default.ctrl?boolean-
options.default.key?stringShould be a keyboardevent code
options.default.keys?string[]Should be keyboardevent codes
options.default.shift?boolean-
options.preventDefault?boolean-
options.titlestringThere should be no duplicate titles within a category
callback(e) => void-

Returns

Function

A function to remove the hotkey

Returns

void


addHotkey()

addHotkey(id, options, callback): () => void

Adds a hotkey with a given id

Parameters

ParameterTypeDescription
idstring-
options{ alt: boolean; ctrl: boolean; key: string; keys: string[]; preventDefault: boolean; shift: boolean; }-
options.alt?boolean-
options.ctrl?boolean-
options.key?stringShould be a keyboardevent code
options.keys?string[]Should be keyboardevent codes
options.preventDefault?boolean-
options.shift?boolean-
callback(e) => void-

Returns

Function

A function to remove the hotkey

Returns

void


releaseAll()

releaseAll(): void

Releases all keys, needed if a hotkey opens something that will prevent keyup events from being registered, such as an alert

Returns

void


removeConfigurableHotkey()

removeConfigurableHotkey(id): void

Removes a configurable hotkey with a given id

Parameters

ParameterType
idstring

Returns

void


removeHotkeys()

removeHotkeys(id): void

Removes all hotkeys with a given id

Parameters

ParameterType
idstring

Returns

void