register
Module @netwiv/api/plugins/global-shortcut · Kind Function
import { register } from '@netwiv/api/plugins/global-shortcut';Register a global shortcut or a list of shortcuts.
The handler is called when any of the registered shortcuts are pressed by the user.
If the shortcut is already taken by another application, the handler will not be triggered. Make sure the shortcut is as unique as possible while still taking user experience into consideration.
Signature
Section titled “Signature”function register(shortcuts: string | string[], handler: ShortcutHandler): Promise<void>Example
Section titled “Example”import { register } from '@netwiv/api/plugins/global-shortcut';
// register a single hotkeyawait register('CommandOrControl+Shift+C', (event) => { if (event.state === "Pressed") { console.log('Shortcut triggered'); }});
// or register multiple hotkeys at onceawait register(['CommandOrControl+Shift+C', 'Alt+A'], (event) => { console.log(`Shortcut ${event.shortcut} triggered`);});Upstream since 2.0.0
Descriptions come from the pinned @tauri-apps/plugin-global-shortcut@2.3.2 declarations (MIT OR Apache-2.0); imports are shown with @netwiv/api paths.