{"record":{"id":"1ae7ee963e976230","repo":"tui-cs/Terminal.Gui","slug":"hotkey-does-not-support-ctrlmask-hotkey","errorCode":null,"errorMessage":"HotKey does not support CtrlMask ({hotKey}).","messagePattern":"HotKey does not support CtrlMask \\((.+?)\\)\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/ViewBase/View.Keyboard.cs","lineNumber":145,"sourceCode":"        if (_hotKey == hotKey)\n        {\n            return false;\n        }\n\n        Key newKey = hotKey;\n\n        Key baseKey = newKey.NoAlt.NoShift.NoCtrl;\n\n        if (newKey != Key.Empty && Rune.IsControl (baseKey.AsRune))\n        {\n            throw new ArgumentException (@$\"HotKey must be a printable key ({hotKey}).\");\n        }\n\n        if (newKey != baseKey)\n        {\n            if (newKey.IsCtrl)\n            {\n                throw new ArgumentException (@$\"HotKey does not support CtrlMask ({hotKey}).\");\n            }\n\n            // Strip off the shift mask if it's A...Z\n            if (baseKey.IsKeyCodeAtoZ)\n            {\n                newKey = newKey.NoShift;\n            }\n\n            // Strip off the Alt mask\n            newKey = newKey.NoAlt;\n        }\n\n        // Remove base version\n        if (HotKeyBindings.TryGet (prevHotKey, out _))\n        {\n            HotKeyBindings.Remove (prevHotKey);\n        }\n","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/ViewBase/View.Keyboard.cs#L127-L163","documentation":"HotKey does not support the Ctrl modifier because Ctrl+letter conflicts with terminal control sequences and the application's own command bindings. Only Alt and Shift (for letters A–Z) are auto-applied. Passing a key with Ctrl set is explicitly rejected.","triggerScenarios":"Setting view.HotKey = Key.A.WithCtrl, Key.Q.WithCtrl, or any Key value where IsCtrl is true.","commonSituations":"Recording a Ctrl+key shortcut and mistakenly assigning it to HotKey; OR-ing Key.CtrlMask into a hot key value.","solutions":["Strip Ctrl with .NoCtrl before assigning, or use a plain Alt+letter.","For Ctrl-based shortcuts, use KeyBindings.Add(key, command) directly."],"exampleFix":"// before\nview.HotKey = Key.S.WithCtrl;\n// after\nview.KeyBindings.Add (Key.S.WithCtrl, Command.Save);","handlingStrategy":"validation","validationCode":"view.HotKey = candidate.IsCtrl ? throw new ArgumentException(\"no ctrl\") : candidate;","typeGuard":"static bool HotKeyHasNoCtrl (Key k) => !k.IsCtrl;","tryCatchPattern":null,"preventionTips":["Strip Ctrl with .NoCtrl before assignment.","Use KeyBindings for Ctrl shortcuts.","Prefer Alt+letter for mnemonics."],"tags":["hotkey","keyboard","ctrl","validation"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}