Skip to content
Tauri
Releases

Global Shortcut

Register global shortcuts.

  • Windows
  • Linux
  • macOS

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

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

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

See Access Control List 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