1. API
  2. globalShortcut

API

Methods for registering/unregistering global keyboard shortcuts for a ToDesktop application.

Remarks

This package exposes a number of methods for registering/unregistering global keyboard shortcuts for a ToDesktop application.

Note: The shortcut is global; it will work even if the app does not have the keyboard focus. This module cannot be used before the ready event of the app module is emitted.

Functions

Function Description
isRegistered(accelerator) Whether this application has registered accelerator.
register(accelerator, handler) Registers a global shortcut of accelerator.
unregister(accelerator) Unregisters a global shortcut of accelerator.
unregisterAll() Unregisters all global shortcuts.

isRegistered()

Whether this application has registered accelerator.

Signature:

        import { globalShortcut } from "@todesktop/client-core"
globalShortcut.isRegistered(accelerator: string): Promise<boolean>;

      
Parameters
Parameter Type Description
accelerator string Keyboard shortcut. See here: https://www.electronjs.org/docs/api/accelerator

Returns:

Promise<boolean>

register()

Registers a global shortcut of accelerator.

Signature:

        import { globalShortcut } from "@todesktop/client-core"
globalShortcut.register(accelerator: string, handler: () => void): Promise<void>;

      
Parameters
Parameter Type Description
accelerator string Keyboard shortcut. See here: https://www.electronjs.org/docs/api/accelerator
handler () => void Called when the registered shortcut is pressed by the user

Returns:

Promise<void>

unregister()

Unregisters a global shortcut of accelerator.

Signature:

        import { globalShortcut } from "@todesktop/client-core"
globalShortcut.unregister(accelerator: string): Promise<void>;

      
Parameters
Parameter Type Description
accelerator string Keyboard shortcut. See here: https://www.electronjs.org/docs/api/accelerator

Returns:

Promise<void>

unregisterAll()

Unregisters all global shortcuts.

Signature:

        import { globalShortcut } from "@todesktop/client-core"
globalShortcut.unregisterAll(): Promise<void>;

      

Returns:

Promise<void>