unregister
Category: Global Hotkeys
Namespace: web.hotkey.unregister
Description
Unregisters a single global hotkey by its ID. The key combination is released back to Windows and will no longer fire web.events.onHotkey.
This call is idempotent — calling it with an ID that isn't currently registered simply returns true without error.
Syntax
const success = await web.hotkey.unregister({ id: 1 });
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id |
integer | Yes | The hotkey ID to unregister, >= 1. |
Returns
boolean — always true. Returns true even if the ID was not currently registered.
Examples
Basic — unregister a specific hotkey
// Register
await web.hotkey.register({ id: 1, key: 'H', modifiers: 'ctrl+alt' });
// Later, unregister just that one
await web.hotkey.unregister({ id: 1 });
Toggle hotkey on/off with a button
let isRegistered = false;
async function toggleHotkey() {
if (isRegistered) {
await web.hotkey.unregister({ id: 1 });
isRegistered = false;
document.getElementById('btn').textContent = 'Enable Hotkey';
} else {
const ok = await web.hotkey.register({ id: 1, key: 'H', modifiers: 'ctrl+alt' });
isRegistered = ok;
document.getElementById('btn').textContent = ok ? 'Disable Hotkey' : 'Enable Hotkey';
}
}
Clean up before closing
// Not strictly required — hotkeys are automatically unregistered
// when the app exits. But useful if you want to release a hotkey
// while the app is still running (e.g., user changed a setting).
web.events.onCloseQuery = async function() {
await web.hotkey.unregister({ id: 1 });
await web.hotkey.unregister({ id: 2 });
await web.app.close();
};
Notes
- Safe to call even if the ID was never registered — no error is thrown
- After unregistering, the key combination is available for other applications to claim
- To unregister all hotkeys at once, use
web.hotkey.unregisterAll()