octobercms/october · error · Error
No hotkey has been defined.
Error message
No hotkey has been defined.
What it means
InputHotkeyControl (registered as the 'input-hotkey' control in October's toolbox) binds keyboard shortcuts declared via data-hotkey / the hotkey option. init() throws when config.hotkey === false — the sentinel ControlBase assigns when neither the attribute nor the option was provided. Note the guard only covers false: a hotkey of undefined would instead crash later in initKeyConditions() at this.config.hotkey.toLowerCase().
Source
Thrown at modules/system/assets/toolbox/controls/input-hotkey/hotkey-control.js:55
right: 39,
down: 40,
f1: 112,
f2: 113,
f3: 114,
f4: 115,
f5: 116,
f6: 117,
f7: 118,
f8: 119,
f9: 120,
f10: 121,
f11: 122,
f12: 123
};
init() {
if (this.config.hotkey === false) {
throw new Error('No hotkey has been defined.');
}
this.hotkeyTarget = this.config.hotkeyTarget || 'html';
this.hotkeyVisible = this.config.hotkeyVisible !== false;
this.callbackFunc = this.element.ocHotKeyControlCallback || function(element) {
element.dispatchEvent(new MouseEvent('click', {
bubbles: true,
cancelable: true,
view: window
}));
return false;
};
}
connect() {
this.initKeyConditions();
View on GitHub (pinned to b608633a7e)
Solutions
- Add the attribute: data-hotkey="ctrl+s" (comma-separated combos allowed: "ctrl+s, cmd+s").
- When initializing from JS, pass the option: hotKey({ hotkey: 'ctrl+s', callback: fn }).
- If no shortcut is intended, remove data-control="input-hotkey" entirely — the control cannot work without a key.
Example fix
<!-- before --> <button data-control="input-hotkey">Save</button> <!-- after --> <button data-control="input-hotkey" data-hotkey="ctrl+s">Save</button>
Defensive patterns
Strategy: validation
Validate before calling
// Before initializing a hotkey control, confirm the config exists
function bindHotkey(el) {
var hotkey = el.getAttribute('data-hotkey');
if (!hotkey) {
console.warn('Skipping input-hotkey: data-hotkey missing on', el);
return;
}
/* proceed with control registration */
} Prevention
- Treat data-hotkey as mandatory wherever data-control="input-hotkey" is emitted.
- In markup linters/CI, flag input-hotkey elements lacking data-hotkey.
- When instantiating programmatically, always pass the hotkey option.
When it happens
Trigger: Markup like <button data-control="input-hotkey"> with no data-hotkey attribute; instantiating the control from JS with an empty config object (hotKey({})); a dynamically generated element where the data-hotkey attribute was dropped.
Common situations: Copy-pasting control markup without the attribute that activates it; renaming data-hotkey to a custom name during refactors; wiring the control programmatically and forgetting the option.
Related errors
- Trigger condition is not specified.
- Trigger selector is not specified.
- Trigger action is not specified.
- command option is not set for toolbar button
- command option is not set for menu item
AI-assisted analysis of octobercms/october@b608633a7e (2026-08-21).
Data as JSON: /api/errors/60612b8f81addc88.
Report an issue: GitHub.