Register global shortcuts.
This package is also accessible with window.__TAURI__.globalShortcut
when tauri.conf.json > build > withGlobalTauri
is set to true.
The APIs must be allowlisted on tauri.conf.json
:
{
"tauri": {
"allowlist": {
"globalShortcut": {
"all": true // enable all global shortcut APIs
}
}
}
}
It is recommended to allowlist only the APIs you use for optimal bundle size and security.
#
Type aliases#
ShortcutHandlerƬ ShortcutHandler: (shortcut
: string
) => void
#
Type declaration▸ (shortcut
): void
#
ParametersName | Type |
---|---|
shortcut | string |
#
Returnsvoid
#
Defined in#
Functions#
isRegistered▸ isRegistered(shortcut
): Promise
<boolean
>
Determines whether the given shortcut is registered by this application or not.
#
ParametersName | Type | Description |
---|---|---|
shortcut | string | Array of shortcut definitions, modifiers and key separated by "+" e.g. CmdOrControl+Q |
#
ReturnsPromise
<boolean
>
A promise resolving to the state.
#
Defined in#
register▸ register(shortcut
, handler
): Promise
<void
>
Register a global shortcut.
#
ParametersName | Type | Description |
---|---|---|
shortcut | string | Shortcut definition, modifiers and key separated by "+" e.g. CmdOrControl+Q |
handler | ShortcutHandler | Shortcut handler callback - takes the triggered shortcut as argument |
#
ReturnsPromise
<void
>
#
Defined in#
registerAll▸ registerAll(shortcuts
, handler
): Promise
<void
>
Register a collection of global shortcuts.
#
ParametersName | Type | Description |
---|---|---|
shortcuts | string [] | Array of shortcut definitions, modifiers and key separated by "+" e.g. CmdOrControl+Q |
handler | ShortcutHandler | Shortcut handler callback - takes the triggered shortcut as argument |
#
ReturnsPromise
<void
>
#
Defined in#
unregister▸ unregister(shortcut
): Promise
<void
>
Unregister a global shortcut.
#
ParametersName | Type | Description |
---|---|---|
shortcut | string | shortcut definition, modifiers and key separated by "+" e.g. CmdOrControl+Q |
#
ReturnsPromise
<void
>
#
Defined in#
unregisterAll▸ unregisterAll(): Promise
<void
>
Unregisters all shortcuts registered by the application.
#
ReturnsPromise
<void
>