---
updatedAt: 2025-05-29T22:38:05.000Z
agentTools:
  projectIndex: https://slobs-platform.readme.io/llms.txt
---

# 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`

<Table align={["left","left","left"]}>
  <thead>
    <tr>
      <th>
        Property
      </th>

      <th>
        Type
      </th>

      <th>
        Description
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        type
      </td>

      <td>
        `up` | `down`
      </td>

      <td>
        Whether 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.
      </td>
    </tr>

    <tr>
      <td>
        key
      </td>

      <td>
        string
      </td>

      <td>
        The 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](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code)
      </td>
    </tr>

    <tr>
      <td>
        modifiers
      </td>

      <td>
        a [KeyModifiers](https://slobs-platform.readme.io/docs/hotkeys-module#section-keymodifiers-object-) object
      </td>

      <td>
        The modifiers for this listener.
      </td>
    </tr>
  </tbody>
</Table>

# KeyModifiers `object`

<Table align={["left","left","left"]}>
  <thead>
    <tr>
      <th>
        Property
      </th>

      <th>
        Type
      </th>

      <th>
        Description
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>
        alt
      </td>

      <td>
        boolean (default = false)
      </td>

      <td>
        Whether this hotkey requires the `alt` key modifier.
      </td>
    </tr>

    <tr>
      <td>
        ctrl
      </td>

      <td>
        boolean (default = false)
      </td>

      <td>
        Whether this hotkey requires the `ctrl` key modifier.
      </td>
    </tr>

    <tr>
      <td>
        meta
      </td>

      <td>
        boolean (default = false)
      </td>

      <td>
        Whether this hotkey requires the `meta` (win) key modifier.
      </td>
    </tr>

    <tr>
      <td>
        shift
      </td>

      <td>
        boolean (default = false)
      </td>

      <td>
        Whether this hotkey requires the `shift` key modifier.
      </td>
    </tr>
  </tbody>
</Table>

# registerKey `method`

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

Registers a hotkey for your app.

### Arguments

1. `keyReference`: A [Key Reference](https://slobs-platform.readme.io/docs/hotkeys-module#section-keyreference-object-) 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

```javascript
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](https://slobs-platform.readme.io/docs/hotkeys-module#section-keyreference-object-) object.

### Returns

None

### Example

```javascript
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.

```javascript
streamlabsOBS.v1.Hotkeys.unregisterAll()
```