@tauri-apps/plugin-global-shortcut
Register global shortcuts.
Functions
Section titled “Functions”isRegistered()
Section titled “isRegistered()”function isRegistered(shortcut: string): Promise<boolean>;Defined in: plugins/global-shortcut/guest-js/index.ts:125
Determines whether the given shortcut is registered by this application or not.
If the shortcut is registered by another application, it will still return false.
Example
Section titled “Example”import { isRegistered } from '@tauri-apps/plugin-global-shortcut';const isRegistered = await isRegistered('CommandOrControl+P');Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
shortcut |
string |
shortcut definition, modifiers and key separated by “+” e.g. CmdOrControl+Q |
Returns
Section titled “Returns”A promise resolving to whether the shortcut is currently registered by this application.
2.0.0
register()
Section titled “register()”function register(shortcuts: string | string[], handler: ShortcutHandler): Promise<void>;Defined in: plugins/global-shortcut/guest-js/index.ts:58
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.
Example
Section titled “Example”import { register } from '@tauri-apps/plugin-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`);});Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
shortcuts |
string | string[] |
A shortcut definition, or a list of shortcut definitions, with modifiers and key separated by “+” e.g. CmdOrControl+Q |
handler |
ShortcutHandler |
Shortcut handler callback - takes the triggered shortcut as argument |
Returns
Section titled “Returns”2.0.0
unregister()
Section titled “unregister()”function unregister(shortcuts: string | string[]): Promise<void>;Defined in: plugins/global-shortcut/guest-js/index.ts:89
Unregister a global shortcut or a list of shortcuts.
Example
Section titled “Example”import { unregister } from '@tauri-apps/plugin-global-shortcut';
// unregister a single hotkeyawait unregister('CmdOrControl+Space');
// or unregister multiple hotkeys at the same timeawait unregister(['CmdOrControl+Space', 'Alt+A']);Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
shortcuts |
string | string[] |
A shortcut definition, or a list of shortcut definitions, with modifiers and key separated by “+” e.g. CmdOrControl+Q |
Returns
Section titled “Returns”2.0.0
unregisterAll()
Section titled “unregisterAll()”function unregisterAll(): Promise<void>;Defined in: plugins/global-shortcut/guest-js/index.ts:105
Unregister all global shortcuts.
Example
Section titled “Example”import { unregisterAll } from '@tauri-apps/plugin-global-shortcut';await unregisterAll();Returns
Section titled “Returns”2.0.0
Interfaces
Section titled “Interfaces”ShortcutEvent
Section titled “ShortcutEvent”Defined in: plugins/global-shortcut/guest-js/index.ts:16
Payload sent to a shortcut handler when a registered shortcut is pressed or released.
Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
id |
number |
Numeric identifier derived from the shortcut’s modifiers and key. | plugins/global-shortcut/guest-js/index.ts:20 |
shortcut |
string |
The shortcut definition that triggered this event, e.g. CommandOrControl+Shift+C. |
plugins/global-shortcut/guest-js/index.ts:18 |
state |
"Released" | "Pressed" |
Whether the shortcut’s key combination was pressed down or released. | plugins/global-shortcut/guest-js/index.ts:22 |
Type Aliases
Section titled “Type Aliases”ShortcutHandler
Section titled “ShortcutHandler”type ShortcutHandler = (event: ShortcutEvent) => void;Defined in: plugins/global-shortcut/guest-js/index.ts:26
Callback invoked with a ShortcutEvent whenever a registered shortcut changes state.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
event |
ShortcutEvent |
Returns
Section titled “Returns”void
© 2026 Tauri Contributors. CC-BY / MIT