Skip to content
Tauri
Releases

@tauri-apps/plugin-global-shortcut

Register global shortcuts.

Type Aliases

ShortcutHandler

ShortcutHandler: (shortcut) => void

Parameters

ParameterType
shortcutstring

Returns

void

Source: index.ts:13

Functions

isRegistered()

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.

Example

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

Since

2.0.0

Parameters

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

Returns

Promise< boolean >

Source: index.ts:86


register()

register(shortcut, handler): Promise< void >

Register a global shortcut.

Example

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

Since

2.0.0

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 >

Source: index.ts:30


registerAll()

registerAll(shortcuts, handler): Promise< void >

Register a collection of global shortcuts.

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

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 >

Source: index.ts:58


unregister()

unregister(shortcut): Promise< void >

Unregister a global shortcut.

Example

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

Since

2.0.0

Parameters

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

Returns

Promise< void >

Source: index.ts:104


unregisterAll()

unregisterAll(): Promise< void >

Unregisters all shortcuts registered by the application.

Example

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

Since

2.0.0

Returns

Promise< void >

Source: index.ts:120


© 2024 Tauri Contributors. CC-BY / MIT