Skip to main content

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

Parameters#
NameType
shortcutstring
Returns#

void

Defined in#

globalShortcut.ts:29

Functions#

isRegistered#

isRegistered(shortcut): Promise<boolean>

Determines whether the given shortcut is registered by this application or not.

Parameters#

NameTypeDescription
shortcutstringArray of shortcut definitions, modifiers and key separated by "+" e.g. CmdOrControl+Q

Returns#

Promise<boolean>

A promise resolving to the state.

Defined in#

globalShortcut.ts:79


register#

register(shortcut, handler): Promise<void>

Register a global shortcut.

Parameters#

NameTypeDescription
shortcutstringShortcut definition, modifiers and key separated by "+" e.g. CmdOrControl+Q
handlerShortcutHandlerShortcut handler callback - takes the triggered shortcut as argument

Returns#

Promise<void>

Defined in#

globalShortcut.ts:38


registerAll#

registerAll(shortcuts, handler): Promise<void>

Register a collection of global shortcuts.

Parameters#

NameTypeDescription
shortcutsstring[]Array of shortcut definitions, modifiers and key separated by "+" e.g. CmdOrControl+Q
handlerShortcutHandlerShortcut handler callback - takes the triggered shortcut as argument

Returns#

Promise<void>

Defined in#

globalShortcut.ts:59


unregister#

unregister(shortcut): Promise<void>

Unregister a global shortcut.

Parameters#

NameTypeDescription
shortcutstringshortcut definition, modifiers and key separated by "+" e.g. CmdOrControl+Q

Returns#

Promise<void>

Defined in#

globalShortcut.ts:95


unregisterAll#

unregisterAll(): Promise<void>

Unregisters all shortcuts registered by the application.

Returns#

Promise<void>

Defined in#

globalShortcut.ts:110