{"record":{"id":"60612b8f81addc88","repo":"octobercms/october","slug":"no-hotkey-has-been-defined","errorCode":null,"errorMessage":"No hotkey has been defined.","messagePattern":"No hotkey has been defined\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"modules/system/assets/toolbox/controls/input-hotkey/hotkey-control.js","lineNumber":55,"sourceCode":"        right: 39,\n        down: 40,\n        f1: 112,\n        f2: 113,\n        f3: 114,\n        f4: 115,\n        f5: 116,\n        f6: 117,\n        f7: 118,\n        f8: 119,\n        f9: 120,\n        f10: 121,\n        f11: 122,\n        f12: 123\n    };\n\n    init() {\n        if (this.config.hotkey === false) {\n            throw new Error('No hotkey has been defined.');\n        }\n\n        this.hotkeyTarget = this.config.hotkeyTarget || 'html';\n        this.hotkeyVisible = this.config.hotkeyVisible !== false;\n\n        this.callbackFunc = this.element.ocHotKeyControlCallback || function(element) {\n            element.dispatchEvent(new MouseEvent('click', {\n                bubbles: true,\n                cancelable: true,\n                view: window\n            }));\n            return false;\n        };\n    }\n\n    connect() {\n        this.initKeyConditions();\n","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/system/assets/toolbox/controls/input-hotkey/hotkey-control.js#L37-L73","documentation":"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().","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"<!-- before -->\n<button data-control=\"input-hotkey\">Save</button>\n\n<!-- after -->\n<button data-control=\"input-hotkey\" data-hotkey=\"ctrl+s\">Save</button>","handlingStrategy":"validation","validationCode":"// Before initializing a hotkey control, confirm the config exists\nfunction bindHotkey(el) {\n    var hotkey = el.getAttribute('data-hotkey');\n    if (!hotkey) {\n        console.warn('Skipping input-hotkey: data-hotkey missing on', el);\n        return;\n    }\n    /* proceed with control registration */\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["frontend","toolbox-controls","hotkey","missing-attribute","input-hotkey"],"backgroundTag":"missing-required-attribute","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}