コンテンツにスキップ

@tauri-apps/plugin-global-shortcut

このコンテンツはまだ日本語訳がありません。

Register global shortcuts.

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/global-shortcut/guest-js/index.ts#L16

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. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/global-shortcut/guest-js/index.ts#L20
shortcut string The shortcut definition that triggered this event, e.g. CommandOrControl+Shift+C. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/global-shortcut/guest-js/index.ts#L18
state "Released" | "Pressed" Whether the shortcut’s key combination was pressed down or released. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/global-shortcut/guest-js/index.ts#L22

type ShortcutHandler = (event) => void;

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/global-shortcut/guest-js/index.ts#L26

Callback invoked with a ShortcutEvent whenever a registered shortcut changes state.

Parameter Type
event ShortcutEvent

void

function isRegistered(shortcut): Promise<boolean>;

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/global-shortcut/guest-js/index.ts#L125

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.

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.

import { isRegistered } from '@tauri-apps/plugin-global-shortcut';
const isRegistered = await isRegistered('CommandOrControl+P');

2.0.0


function register(shortcuts, handler): Promise<void>;

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/global-shortcut/guest-js/index.ts#L58

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.

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>

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`);
});

2.0.0


function unregister(shortcuts): Promise<void>;

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/global-shortcut/guest-js/index.ts#L89

Unregister a global shortcut or a list of shortcuts.

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>

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']);

2.0.0


function unregisterAll(): Promise<void>;

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/global-shortcut/guest-js/index.ts#L105

Unregister all global shortcuts.

Promise<void>

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

2.0.0


© 2026 Tauri Contributors. CC-BY / MIT