HotkeyManager
Unofficial
Manager for keyboard shortcut registration, storage, and triggering.
Import:
import type { HotkeyManager } from '@obsidian-typings/obsidian-catalyst-latest';Signature:
export interface HotkeyManagerConstructor
new HotkeyManager(app: App)Constructor.
To get the constructor instance, use getHotkeyManagerConstructor from obsidian-typings/implementations.
Properties
| Property | Type | Description | |
|---|---|---|---|
| app | App | Reference to the obsidian#App. | |
| baked | boolean | Whether hotkeys have been baked (checks completed). | |
| bakedHotkeys | KeymapInfo[] | Assigned hotkeys. | |
| bakedIds | string[] | Array of hotkey index to command ID. | |
| customKeys | HotkeyManagerCustomKeysRecord | Custom (non-Obsidian default) hotkeys, one to many mapping of command ID to assigned hotkey. | |
| defaultKeys | HotkeyManagerDefaultKeysRecord | Default hotkeys, one to many mapping of command ID to assigned hotkey. | |
| onConfigFileChange | Debouncer<[], Promise<void>> | Debounced handler for hotkey config file changes on disk. |
Methods
| Method | Returns | Description | |
|---|---|---|---|
| addDefaultHotkeys(command, keys) | void | Add a hotkey to the default hotkeys. | |
| bake() | void | Bake 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() | void | Load hotkeys from storage. | |
| onRaw(e) | void | Handle raw file system change events for the hotkey config. | |
| onTrigger(event, keypress) | boolean | Trigger a command by keyboard event. | |
| printHotkeyForCommand(commandId) | string | Pretty-print hotkey of a command. | |
| registerListeners() | void | Register event listeners for hotkey config file changes. | |
| removeDefaultHotkeys(command) | void | Remove a hotkey from the default hotkeys. | |
| removeHotkeys(command) | void | Remove a hotkey from the custom hotkeys. | |
| save() | void | Save custom hotkeys to storage. | |
| setHotkeys(command, keys) | void | Add a hotkey to the custom hotkeys (overrides default hotkeys). |
Links to this page: