Skip to content

@tauri-apps/plugin-global-shortcut

Register global shortcuts.

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.

import { isRegistered } from '@tauri-apps/plugin-global-shortcut';
const isRegistered = await isRegistered('CommandOrControl+P');
Parameter Type Description
shortcut string shortcut definition, modifiers and key separated by “+” e.g. CmdOrControl+Q

Promise<boolean>

A promise resolving to whether the shortcut is currently registered by this application.

2.0.0


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.

import { register } from '@tauri-apps/plugin-global-shortcut';
// register a single hotkey
await register('CommandOrControl+Shift+C', (event) => {
if (event.state === "Pressed") {
console.log('Shortcut triggered');
}
});
// or register multiple hotkeys at once
await register(['CommandOrControl+Shift+C', 'Alt+A'], (event) => {
console.log(`Shortcut ${event.shortcut} triggered`);
});
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

Promise<void>

2.0.0


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.

import { unregister } from '@tauri-apps/plugin-global-shortcut';
// unregister a single hotkey
await unregister('CmdOrControl+Space');
// or unregister multiple hotkeys at the same time
await unregister(['CmdOrControl+Space', 'Alt+A']);
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

Promise<void>

2.0.0


function unregisterAll(): Promise<void>;

Defined in: plugins/global-shortcut/guest-js/index.ts:105

Unregister all global shortcuts.

import { unregisterAll } from '@tauri-apps/plugin-global-shortcut';
await unregisterAll();

Promise<void>

2.0.0

Defined in: plugins/global-shortcut/guest-js/index.ts:16

Payload sent to a shortcut handler when a registered shortcut is pressed or released.

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 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.

Parameter Type
event ShortcutEvent

void


© 2026 Tauri Contributors. CC-BY / MIT