コンテンツにスキップ
Tauri

Global Shortcut(グローバル・ショートカット)

《訳注》

Plugin 説明内容の英語表記部分について Plugin の各章は、原文データからページ内容の一部が自動生成されているため、英語表記のままの部分があります。

グローバルショートカットを登録します。

This plugin requires a Rust version of at least 1.77.2

Platform Level Notes
windows
linux
macos
android
ios

はじめに、「Global Shortcut グローバル・ショートカット」プラグインをインストールしてください。

自分のプロジェクトのパッケージ・マネージャーを使用して依存関係を追加します:

npm run tauri add global-shortcut

「グローバル・ショートカット global-shortcut」プラグインは JavaScript と Rust の両方で利用可能です。

import { register } from '@tauri-apps/plugin-global-shortcut';
// `"withGlobalTauri": true` を使用する場合は、
// const { register } = window.__TAURI__.globalShortcut; を使用できます
await register('CommandOrControl+Shift+C', () => {
console.log('Shortcut triggered');
});

デフォルトでは、潜在的に危険なプラグイン・コマンドとそのスコープ(有効範囲)はすべてブロックされており、アクセスできません。これらを有効にするには、capabilities 設定でアクセス権限を変更する必要があります。

詳細については「セキュリティ・レベル Capabilities」の章を参照してください。また、プラグインのアクセス権限を設定するには「プライグン・アクセス権の使用」の章のステップ・バイ・ステップ・ガイドを参照してください。

src-tauri/capabilities/default.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"
]
}

Default Permission

No features are enabled by default, as we believe the shortcuts can be inherently dangerous and it is application specific if specific shortcuts should be registered or unregistered.

Permission Table

Identifier Description

global-shortcut:allow-is-registered

Enables the is_registered command without any pre-configured scope.

global-shortcut:deny-is-registered

Denies the is_registered command without any pre-configured scope.

global-shortcut:allow-register

Enables the register command without any pre-configured scope.

global-shortcut:deny-register

Denies the register command without any pre-configured scope.

global-shortcut:allow-register-all

Enables the register_all command without any pre-configured scope.

global-shortcut:deny-register-all

Denies the register_all command without any pre-configured scope.

global-shortcut:allow-unregister

Enables the unregister command without any pre-configured scope.

global-shortcut:deny-unregister

Denies the unregister command without any pre-configured scope.

global-shortcut:allow-unregister-all

Enables the unregister_all command without any pre-configured scope.

global-shortcut:deny-unregister-all

Denies the unregister_all command without any pre-configured scope.

【※ この日本語版は、「Feb 22, 2025 英語版」に基づいています】


© 2025 Tauri Contributors. CC-BY / MIT