unregisterAll
Category: Global Hotkeys
Namespace: web.hotkey.unregisterAll
Description
Unregisters every global hotkey that the app has registered. All key combinations are released back to Windows.
This is a convenience method — equivalent to calling web.hotkey.unregister() for each registered ID.
Syntax
const success = await web.hotkey.unregisterAll();
Parameters
None.
Returns
boolean — true on success.
Examples
Basic — clear all hotkeys
// Register several hotkeys
await web.hotkey.register({ id: 1, key: 'H', modifiers: 'ctrl+alt' });
await web.hotkey.register({ id: 2, key: 'F12', modifiers: 'ctrl+shift' });
await web.hotkey.register({ id: 3, key: 'N', modifiers: 'ctrl+alt' });
// Remove them all at once
await web.hotkey.unregisterAll();
Reset hotkeys when changing pages or modes
async function enterEditMode() {
// Clear any existing hotkeys
await web.hotkey.unregisterAll();
// Register edit-mode hotkeys
web.events.onHotkey = async function(id) {
if (id === 1) await saveDocument();
if (id === 2) await publishDocument();
};
await web.hotkey.register({ id: 1, key: 'S', modifiers: 'ctrl+alt' });
await web.hotkey.register({ id: 2, key: 'P', modifiers: 'ctrl+alt' });
}
async function enterViewMode() {
await web.hotkey.unregisterAll();
web.events.onHotkey = async function(id) {
if (id === 1) await nextItem();
if (id === 2) await previousItem();
};
await web.hotkey.register({ id: 1, key: 'RIGHT', modifiers: 'ctrl+alt' });
await web.hotkey.register({ id: 2, key: 'LEFT', modifiers: 'ctrl+alt' });
}
Notes
- Safe to call even when no hotkeys are registered
- All hotkeys are also automatically unregistered when the app closes, so calling this in a close handler is optional