Skip to content

Hotkeys Api

Tools for creating arbitrary hotkeys

get pressed(): Set<string>

Which key codes are currently being pressed

Set<string>

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

Adds a hotkey which can be changed by the user

Parameter Type Description
options { category: string; default?: { alt?: boolean; ctrl?: boolean; key?: string; keys?: readonly string[]; shift?: boolean; }; preventDefault?: boolean; stopPropagation?: boolean; title: string; } -
options.category string -
options.default? { alt?: boolean; ctrl?: boolean; key?: string; keys?: readonly string[]; shift?: boolean; } -
options.default.alt? boolean -
options.default.ctrl? boolean -
options.default.key? string Should be a keyboardevent code
options.default.keys? readonly string[] Should be keyboardevent codes
options.default.shift? boolean -
options.preventDefault? boolean If set to false, the hotkey will still trigger default actions
options.stopPropagation? boolean If set to true, the hotkey will have propagation and immediate propagation stopped, which generally prevents Gimkit from detecting the keystroke
options.title string There should be no duplicate titles within a category
callback (e) => void -

A function to remove the hotkey

() => void

api.hotkeys.addConfigurableHotkey({
category: "My Plugin",
title: "Do a thing",
preventDefault: true,
default: {
key: "Digit1",
ctrl: true,
shift: true
}
}, (e) => {
console.log("Configurable hotkey pressed", e.key);
});

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

Adds a hotkey which will fire when certain keys are pressed

Parameter Type Description
options { alt?: boolean; ctrl?: boolean; key?: string; keys?: readonly string[]; preventDefault?: boolean; shift?: boolean; stopPropagation?: boolean; } -
options.alt? boolean -
options.ctrl? boolean -
options.key? string Should be a keyboardevent code
options.keys? readonly string[] Should be keyboardevent codes
options.preventDefault? boolean If set to false, the hotkey will still trigger default actions
options.shift? boolean -
options.stopPropagation? boolean If set to true, the hotkey will have propagation and immediate propagation stopped, which generally prevents Gimkit from detecting the keystroke
callback (e) => void -

A function to remove the hotkey

() => void

api.hotkeys.addHotkey({
key: "Digit1",
ctrl: true,
shift: true,
preventDefault: true
}, (e) => {
console.log("Hotkey pressed", e.key);
});

releaseAll(): void

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

void