콘텐츠로 이동

register

이 콘텐츠는 아직 번역되지 않았습니다.

Module @netwiv/api/plugins/global-shortcut · Kind Function

import { register } from '@netwiv/api/plugins/global-shortcut';

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.

function register(shortcuts: string | string[], handler: ShortcutHandler): Promise<void>
import { register } from '@netwiv/api/plugins/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`);
});

Upstream since 2.0.0


Descriptions come from the pinned @tauri-apps/plugin-global-shortcut@2.3.2 declarations (MIT OR Apache-2.0); imports are shown with @netwiv/api paths.