Hotkeys - Exit-9B/MCM-Helper GitHub Wiki

About Hotkeys

Hotkeys are a powerful feature of MCM Helper that allows for the execution of a mod action when a key is pressed.

Mods can expose their hotkeys in the MCM, where users can configure which key to use for each action. Attempting to bind a key already bound to a mod action or an existing in-game function will result in a warning message (mod authors can suppress these on a case-by-case basis). Users may still choose to ignore the warning and keep the conflict if they wish.

Defining Hotkeys

All hotkeys that a mod provides must be defined in MCM\Config\ModName\keybinds.json.

A hotkey must have an ID, a short description (for conflict resolution purposes), and an associated action.

Action Types

1. CallFunction

Calls a Papyrus function on the specified form.

2. CallGlobalFunction

Calls a global Papyrus function on the specified script.

3. SendEvent

Sends the OnControlDown/OnControlUp event to the specified form with the keybind's ID as the control name.
This action type can be used to determine whether a key is currently being held down.

4. RunConsoleCommand

Runs the specified console command. This will also log the command to the command console.

Example

{
  "$schema": "https://raw.githubusercontent.com/Exit-9B/MCM-Helper/main/docs/keybinds.schema.json",
  "modName": "MCM_Demo",
  "keybinds": [
    {
      "id": "demoHotkey1",
      "desc": "Display Messagebox via CallFunction",
      "action": {
        "type": "CallFunction",
        "form": "MCM_Demo.esp|800",
        "scriptName": "MCM_DemoScript",
        "function": "ShowMessageBox",
        "params": ["Hello world!"]
      }
    },
    {
      "id": "demoHotkey2",
      "desc": "Display Messagebox via CallGlobalFunction",
      "action": {
        "type": "CallGlobalFunction",
        "script": "Debug",
        "function": "MessageBox",
        "params": ["Hello world! (via global function)"]
      }
    },
    {
      "id": "demoHotkey3",
      "desc": "Toggle Menu Display",
      "action": {
        "type": "RunConsoleCommand",
        "command": "ToggleMenus"
      }
    },
    {
      "id": "demoHotkey4",
      "desc": "Notification Demo",
      "action": {
        "type": "SendEvent",
        "form": "MCM_Demo.esp|800",
        "scriptName": "MCM_DemoScript"
      }
    }
  ]
}

The form field accepts the plugin name and the form ID of the form that you want to call a function on. In most cases, this form is a Quest.

For example, if your quest has the formID 0000173E, then you would specify "MyMod.esp|173E" as the form parameter. This, along with the scriptName property, tells MCM Helper where the function is located.