Defined in: app-hotkeys.ts:407
Holds declared app hotkeys and the user's custom hotkeys. Framework providers create one and expose it through hooks; devtools read it from HotkeyManager.appHotkeys.
const store = new AppHotkeysStore(appHotkeys, {
customHotkeys: JSON.parse(localStorage.getItem('hotkeys') ?? '{}'),
onCustomHotkeysChange: (custom) =>
localStorage.setItem('hotkeys', JSON.stringify(custom)),
})
store.setCustomHotkey('doc.save', 'Mod+Shift+S')T extends AppHotkeys = AppHotkeys
new AppHotkeysStore<T>(appHotkeys, options?): AppHotkeysStore<T>;Defined in: app-hotkeys.ts:414
T
AppHotkeysStoreOptions<T> = {}
AppHotkeysStore<T>
readonly store: Store<AppHotkeysState<T>>;Defined in: app-hotkeys.ts:408
get appHotkeys(): T;Defined in: app-hotkeys.ts:433
Effective app hotkeys.
T
get customHotkeys(): CustomHotkeys<T>;Defined in: app-hotkeys.ts:438
The user's hotkeys that differ from the defaults.
findConflicts(id, hotkey): AppHotkey<string,
| HotkeyChord
| HotkeySequence
| null>[];Defined in: app-hotkeys.ts:512
Other app hotkeys that would collide if id used hotkey. App hotkeys collide when their scopes match or either is 'global', and their hotkeys are equal or one sequence starts with the other.
keyof T & string
AppHotkey<string, | HotkeyChord | HotkeySequence | null>[]
get(id):
| AppHotkey<string,
| HotkeyChord
| HotkeySequence
| null>
| undefined;Defined in: app-hotkeys.ts:502
Effective app hotkey for an id, or undefined when it is not declared.
string
| AppHotkey<string, | HotkeyChord | HotkeySequence | null> | undefined
getList(registrations): AppHotkeyListItem<T[keyof T]>[];Defined in: app-hotkeys.ts:576
Joins app hotkeys with live registrations, in declaration order. Adapters call this with the manager's registration views.
Iterable<HotkeyRegistrationView>
AppHotkeyListItem<T[keyof T]>[]
resetCustomHotkey(id): void;Defined in: app-hotkeys.ts:553
Restores the default hotkey for an app hotkey.
keyof T & string
void
resetCustomHotkeys(): void;Defined in: app-hotkeys.ts:560
Restores every default hotkey.
void
setAppHotkeys(appHotkeys): void;Defined in: app-hotkeys.ts:488
Replaces the declarations, for example after hot module replacement. Custom hotkeys for ids that still exist are kept.
T
void
setCustomHotkey(id, hotkey): AppHotkey<string,
| HotkeyChord
| HotkeySequence
| null>[];Defined in: app-hotkeys.ts:531
Sets the user's hotkey for an app hotkey. null unbinds it. A hotkey equal to the default removes the customization.
keyof T & string
Hotkey | null
AppHotkey<string, | HotkeyChord | HotkeySequence | null>[]
Conflicting app hotkeys. When any exist, nothing changes.
setOptions(options): void;Defined in: app-hotkeys.ts:452
Updates options. Providers call it with their props on every update.
When customHotkeys differs from the value last passed in, it replaces the current custom hotkeys. An equal value, such as the same saved data parsed again, keeps changes the user made since. undefined changes nothing, such as while saved data loads; null clears them, such as on sign-out. Replacing does not call onCustomHotkeysChange, because the data came from the app.
void