The global-shortcut module registers global hotkeys that fire even
when the app is not focused. It is a port of Tauri's
tauri-plugin-global-shortcut, backed by the built-in
plugin:global-shortcut|* commands and the ztron://global-shortcut
event (the macOS side uses Carbon's Register/UnregisterEventHotKey).
Registration returns a boolean — whether the OS accepted it (false when
the shortcut is taken by another app) — rather than succeeding
unconditionally.
global-shortcut consists of framework built-in commands: the 5
plugin:global-shortcut|* commands are registered into the permission
table with the other built-in commands and granted by the
core:default set. No plugin construction, no scope.
Register/unregister round trip (actually pressing the hotkey is manual;
the spike verifies the command path). From
examples/hello/frontend/src/main.ts (the anchor SHORTCUT_OK is its
real run output):
The isRegistered state-query round trip (P22; the anchor
SHORTCUT_ISREG_OK is its real run output; comments kept, excerpts
elided):
Activation listening: onShortcut((e) => e.shortcutId)
(ztron://global-shortcut, payload is the registered id); batch
registration registerAll([{ id, accelerator }]) returns per-entry
success flags in order; unregisterAll() unregisters every hotkey
registered by this process. Accelerators look like Cmd+Shift+K,
Ctrl+Alt+1, F5.
plugin:global-shortcut|* totals 5 commands, mapped one-to-one to
the API:
| Command | API |
|---|---|
register / unregister |
registerShortcut / unregisterShortcut |
register_all / unregister_all |
registerAll / unregisterAll |
is_registered |
isRegistered |
Full list in the Commands Reference and the API symbol reference.
Applicable version: ztron 0.3.1