Global Shortcuts

Methods

Register Shortcut

Sets the app to listen for the specific keys to be pressed, even if the app is not in focus.

When the accelerator is already taken by other applications, this call will silently fail. This behavior is intended by operating systems, since they don't want applications to fight for global shortcuts.

await window.deskifier.shortcuts.register({ arguments })

Arguments

  • accelerator String
    The specific trigger keys. Check here for available keys.
  • id String (Optional)
    The ID of the shortcut. If none is given, one will be randomly generated.

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.
  • id String
    The ID of the shortcut. If none is given, one will be randomly generated.

Example

const result = await window.deskifier.shortcuts.register({
    accelerator: 'CommandOrControl+Y',
    id: 'abc123'
});

console.log(result.id);  // abc123

Unregister Shortcut

Unregisters the shortcut.

await window.deskifier.shortcuts.unregister({ arguments })

Arguments

  • id String (Required)

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.

Unregister All Shortcuts

Unregisters all shortcuts.

await window.deskifier.shortcuts.unregisterAll()

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.

Properties

Get Shortcuts

Retrieves all of the registered shortcuts by the application.

If a registered accelerator is already taken by other applications, this call will still return it as registered. This behavior is intended by operating systems, since they don't want applications to fight for global shortcuts.

await window.deskifier.shortcuts.getAll()

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.
  • shortcuts Array of Objects, each with:
    • accelerator String
    • id String

Events

Shortcut Triggered

Fires when a shortcut is used.

window.deskifier.shortcuts.onTriggered((data) => { })

Arguments

  • accelerator String
  • id String