Hotkeys Module

Required Permissions: slobs.hotkeys

This module allows your app to register a listener for global hotkeys. These hotkeys are registered with the operating system, and will be triggered regardless of what application is currently in focus. Currently these keybindings are not persisted anywhere. Your app is responsible for binding these on startup each time. Your page should run in persistent mode if you want to be able to respond to hotkeys when your app page is not in focus.

Minimum Version

This was module was added in Build 8 of the Streamlabs OBS App Developer build.

KeyReference object

PropertyTypeDescription
typeup | downWhether this refers to a key-up or key-down listener. If you are implementing momentary-press hotkey, then you should bind behavior on both up and down.
keystringThe key code of the key you want to bind. This is the same as the event.code string that is provided by DOM KeyboardEvent listeners. For a full list of available keys, look here
modifiersa KeyModifiers objectThe modifiers for this listener.

KeyModifiers object

PropertyTypeDescription
altboolean (default = false)Whether this hotkey requires the alt key modifier.
ctrlboolean (default = false)Whether this hotkey requires the ctrl key modifier.
metaboolean (default = false)Whether this hotkey requires the meta (win) key modifier.
shiftboolean (default = false)Whether this hotkey requires the shift key modifier.

registerKey method

registerKey(keyReference: KeyReference, callback: Function): boolean

Registers a hotkey for your app.

Arguments

  1. keyReference: A Key Reference object.
  2. callback: A callback function that will be called when the key is pressed

Returns

This function returns true if the callback was successfully bound, otherwise it returns false.

Example

streamlabsOBS.v1.Hotkeys.registerKey(
  {
    type: 'up',
    key: 'KeyF',
    modifiers: {
      alt: true,
      shift: true
    }
  },
  () => console.log('Key Pressed!')
);

unregisterKey method

unregisterKey(keyReference: KeyReference): void

Unregisters your callback for the given reference.

Arguments

  1. keyReference: A Key Reference object.

Returns

None

Example

streamlabsOBS.v1.Hotkeys.unregisterKey(
  {
    type: 'up',
    key: 'KeyF',
    modifiers: {
      alt: true,
      shift: true
    }
  }
);

unregisterAll method

unregisterAll(): void

This method will unregister all keys for your app.

streamlabsOBS.v1.Hotkeys.unregisterAll()