AboutSupportDeveloper GuideVersion 40.130.100.7

The GlobalHotkey module can register/unregister a global hotkeys.

Hierarchy

Accessors

  • get me(): Identity
  • Returns Identity

    me should only be accessed from the fin global (FinApi.me); access through entity classes is not guaranteed to behave sensibly in all calling contexts.

Methods

  • Returns (string | symbol)[]

  • Checks if a given hotkey has been registered by an application within the current runtime.

    Parameters

    • hotkey: string

      a hotkey string

    Returns Promise<boolean>

    const hotkey = 'CommandOrControl+X';

    fin.GlobalHotkey.isRegistered(hotkey)
    .then((registered) => {
    console.log(`hotkey ${hotkey} is registered ? ${registered}`);
    })
    .catch(err => {
    console.log('Error unregistering the hotkey', err);
    });
  • Parameters

    • type: string | symbol

    Returns number

  • Parameters

    • type: string | symbol

    Returns Function[]

  • Registers a global hotkey with the operating system.

    Parameters

    • hotkey: string

      a hotkey string

    • listener: ((...args: any[]) => void)

      called when the registered hotkey is pressed by the user.

        • (...args): void
        • Parameters

          • Rest...args: any[]

          Returns void

    Returns Promise<void>

    If the hotkey is reserved, see list below.

    if the hotkey is already registered by another application.

    The hotkey parameter expects an electron compatible accelerator and the listener will be called if the hotkey is pressed by the user. If successfull, the hotkey will be 'claimed' by the application, meaning that this register call can be called multiple times from within the same application but will fail if another application has registered the hotkey.
    The register call will fail if given any of these reserved Hotkeys:

    • CommandOrControl+0
    • CommandOrControl+=
    • CommandOrControl+Plus
    • CommandOrControl+-
    • CommandOrControl+_
    • CommandOrControl+Shift+I
    • F5
    • CommandOrControl+R
    • Shift+F5
    • CommandOrControl+Shift+R

    Raises the registered event.

    const hotkey = 'CommandOrControl+X';

    fin.GlobalHotkey.register(hotkey, () => {
    console.log(`${hotkey} pressed`);
    })
    .then(() => {
    console.log('Success');
    })
    .catch(err => {
    console.log('Error registering the hotkey', err);
    });
  • Removes all listeners, or those of the specified event.

    Parameters

    • OptionaleventType: "registered" | "unregistered"

    Returns Promise<GlobalHotkey>

  • Unregisters a global hotkey with the operating system.

    Parameters

    • hotkey: string

      a hotkey string

    Returns Promise<void>

    This method will unregister all existing registrations of the hotkey within the application. Raises the unregistered event.

    const hotkey = 'CommandOrControl+X';

    fin.GlobalHotkey.unregister(hotkey)
    .then(() => {
    console.log('Success');
    })
    .catch(err => {
    console.log('Error unregistering the hotkey', err);
    });
  • Unregisters all global hotkeys for the current application.

    Returns Promise<void>

    Raises the unregistered event for each hotkey unregistered.

    fin.GlobalHotkey.unregisterAll()
    .then(() => {
    console.log('Success');
    })
    .catch(err => {
    console.log('Error unregistering all hotkeys for this application', err);
    });