Skip to content
Tauri
Releases

@tauri-apps/plugin-global-shortcut

Register global shortcuts.

Type Aliases

ShortcutHandler()

type ShortcutHandler: (shortcut) => void;

Parameters

ParameterType
shortcutstring

Returns

void

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

Functions

isRegistered()

function isRegistered(shortcut): Promise<boolean>

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.

Parameters

ParameterTypeDescription
shortcutstringshortcut definition, modifiers and key separated by ”+” e.g. CmdOrControl+Q

Returns

Promise<boolean>

Example

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

Since

2.0.0

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


register()

function register(shortcut, handler): Promise<void>

Register a global shortcut.

Parameters

ParameterTypeDescription
shortcutstringShortcut definition, modifiers and key separated by ”+” e.g. CmdOrControl+Q
handlerShortcutHandlerShortcut handler callback - takes the triggered shortcut as argument

Returns

Promise<void>

Example

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

Since

2.0.0

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


registerAll()

function registerAll(shortcuts, handler): Promise<void>

Register a collection of global shortcuts.

Parameters

ParameterTypeDescription
shortcutsstring[]Array of shortcut definitions, modifiers and key separated by ”+” e.g. CmdOrControl+Q
handlerShortcutHandlerShortcut handler callback - takes the triggered shortcut as argument

Returns

Promise<void>

Example

import { registerAll } from '@tauri-apps/plugin-global-shortcut';
await registerAll(['CommandOrControl+Shift+C', 'Ctrl+Alt+F12'], (shortcut) => {
console.log(`Shortcut ${shortcut} triggered`);
});

Since

2.0.0

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


unregister()

function unregister(shortcut): Promise<void>

Unregister a global shortcut.

Parameters

ParameterTypeDescription
shortcutstringshortcut definition, modifiers and key separated by ”+” e.g. CmdOrControl+Q

Returns

Promise<void>

Example

import { unregister } from '@tauri-apps/plugin-global-shortcut';
await unregister('CmdOrControl+Space');

Since

2.0.0

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


unregisterAll()

function unregisterAll(): Promise<void>

Unregisters all shortcuts registered by the application.

Returns

Promise<void>

Example

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

Since

2.0.0

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


© 2024 Tauri Contributors. CC-BY / MIT