Skip to content

HotkeyManager

Unofficial

Manager for keyboard shortcut registration, storage, and triggering.

Import:

import type { HotkeyManager } from '@obsidian-typings/obsidian-public-latest';

Signature:

export interface HotkeyManager

Constructor

new HotkeyManager(app: App)

Constructor.

To get the constructor instance, use getHotkeyManagerConstructor from obsidian-typings/implementations.

Properties

PropertyTypeDescription
appAppReference to the obsidian#App.
bakedbooleanWhether hotkeys have been baked (checks completed).
bakedHotkeysKeymapInfo[]Assigned hotkeys.
bakedIdsstring[]Array of hotkey index to command ID.
customKeysHotkeyManagerCustomKeysRecordCustom (non-Obsidian default) hotkeys, one to many mapping of command ID to assigned hotkey.
defaultKeysHotkeyManagerDefaultKeysRecordDefault hotkeys, one to many mapping of command ID to assigned hotkey.
onConfigFileChangeDebouncer<[], Promise<void>>Debounced handler for hotkey config file changes on disk.

Methods

MethodReturnsDescription
addDefaultHotkeys(command, keys)voidAdd a hotkey to the default hotkeys.
bake()voidBake hotkeys (create mapping of pressed key to command ID).
getDefaultHotkeys(command)KeymapInfo[]Get hotkey associated with command ID.
getHotkeys(command)KeymapInfo[]Get hotkey associated with command ID.
load()voidLoad hotkeys from storage.
onRaw(e)voidHandle raw file system change events for the hotkey config.
onTrigger(event, keypress)booleanTrigger a command by keyboard event.
printHotkeyForCommand(commandId)stringPretty-print hotkey of a command.
registerListeners()voidRegister event listeners for hotkey config file changes.
removeDefaultHotkeys(command)voidRemove a hotkey from the default hotkeys.
removeHotkeys(command)voidRemove a hotkey from the custom hotkeys.
save()voidSave custom hotkeys to storage.
setHotkeys(command, keys)voidAdd a hotkey to the custom hotkeys (overrides default hotkeys).

Links to this page: