Skip to content
Tauri

Global Shortcut

Register global shortcuts.

Supported Platforms

  • Windows
  • Linux
  • macOS

Setup

This plugin requires a Rust version of at least 1.75

Install the global-shortcut plugin to get started.

Use your project’s package manager to add the dependency:

npm run tauri add global-shortcut

Usage

The global-shortcut plugin is available in both JavaScript and Rust.

import { register } from '@tauri-apps/plugin-global-shortcut';
await register('CommandOrControl+Shift+C', () => {
console.log('Shortcut triggered');
});

Permissions

By default all plugin commands are blocked and cannot be accessed. You must define a list of permissions in your capabilities configuration.

See Permissions Overview for more information.

src-tauri/capabilities/main.json
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "main-capability",
"description": "Capability for the main window",
"windows": ["main"],
"permissions": [
"global-shortcut:allow-is-registered",
"global-shortcut:allow-register",
"global-shortcut:allow-unregister"
]
}
PermissionDescription
global-shortcut:allow-is-registeredEnables the is_registered command without any pre-configured scope.
global-shortcut:deny-is-registeredDenies the is_registered command without any pre-configured scope.
global-shortcut:allow-registerEnables the register command without any pre-configured scope.
global-shortcut:deny-registerDenies the register command without any pre-configured scope.
global-shortcut:allow-register-allEnables the register_all command without any pre-configured scope.
global-shortcut:deny-register-allDenies the register_all command without any pre-configured scope.
global-shortcut:allow-unregisterEnables the unregister command without any pre-configured scope.
global-shortcut:deny-unregisterDenies the unregister command without any pre-configured scope.
global-shortcut:allow-unregister-allEnables the unregister_all command without any pre-configured scope.
global-shortcut:deny-unregister-allDenies the unregister_all command without any pre-configured scope.

© 2024 Tauri Contributors. CC-BY / MIT