{"record":{"id":"d2283a2f7a1ddfe0","repo":"helix-editor/helix","slug":"invalid-key-code","errorCode":null,"errorMessage":"Invalid key code '{}'","messagePattern":"Invalid key code '(.+?)'","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"helix-view/src/input.rs","lineNumber":416,"sourceCode":"            }\n            // Checking that the last token is empty ensures that this branch is only taken if\n            // `-` is used as a code. For example this branch will not be taken for `S-` (which is\n            // missing a code).\n            _ if s.ends_with('-') && tokens.last().is_some_and(|t| t.is_empty()) => {\n                if s == \"-\" {\n                    return Ok(KeyEvent {\n                        code: KeyCode::Char('-'),\n                        modifiers: KeyModifiers::empty(),\n                    });\n                } else {\n                    let suggestion = format!(\"{}-{}\", s.trim_end_matches('-'), keys::MINUS);\n                    return Err(anyhow!(\n                        \"Key '-' cannot be used with modifiers, use '{}' instead\",\n                        suggestion\n                    ));\n                }\n            }\n            invalid => return Err(anyhow!(\"Invalid key code '{}'\", invalid)),\n        };\n\n        let mut modifiers = KeyModifiers::empty();\n        for token in tokens {\n            let flag = match token {\n                \"S\" => KeyModifiers::SHIFT,\n                \"A\" => KeyModifiers::ALT,\n                \"C\" => KeyModifiers::CONTROL,\n                \"Meta\" | \"Cmd\" | \"Win\" => KeyModifiers::SUPER,\n                _ => return Err(anyhow!(\"Invalid key modifier '{}-'\", token)),\n            };\n\n            if modifiers.contains(flag) {\n                return Err(anyhow!(\"Repeated key modifier '{}-'\", token));\n            }\n            modifiers.insert(flag);\n        }\n","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/helix-editor/helix/blob/079a789e8cb08ead67f19e1971a1b7438b37354b/helix-view/src/input.rs#L398-L434","documentation":"This is the catch-all branch of KeyEvent::from_str: the final token matched none of the named keys (backspace, ret, left, ..., esc, space, minus, lt, gt, media/modifier keys), is not a single character, and is not an F-key pattern. The offending token is echoed so you can see exactly what failed to match.","triggerScenarios":"Keymap entries with unrecognized key names: \"C-return\" (correct name is \"ret\"), \"C-escape\" (correct is \"esc\"), \"C-delete\" (correct is \"del\"), multi-char strings like \"C-ab\", or typos like \"spce\".","commonSituations":"Guessing long-form key names (return/escape/delete/insert) when Helix uses the short forms ret/esc/del/ins; porting keymaps from other editors whose naming differs; invisible whitespace copied into the config.","solutions":["Use Helix's key names: ret, esc, space, tab, del, ins, backspace, home, end, pageup, pagedown, up, down, left, right, minus, lt, gt, capslock, numlock, F1-F24, etc.","Single characters (letters, digits, punctuation other than '-') can be used directly, e.g. \"C-x\".","Check for trailing spaces or smart quotes around the token in the config file."],"exampleFix":"# before (config.toml)\n \"C-return\" = \"code_action\"\n\n# after\n \"C-ret\" = \"code_action\"","handlingStrategy":"validation","validationCode":"const KEY_NAMES: &[&str] = &[\"backspace\",\"ret\",\"left\",\"right\",\"up\",\"down\",\"home\",\"end\",\n    \"pageup\",\"pagedown\",\"tab\",\"del\",\"ins\",\"null\",\"esc\",\"space\",\"minus\",\"lt\",\"gt\",\n    \"capslock\",\"scrolllock\",\"numlock\",\"printscreen\",\"pause\",\"menu\",\"keypadbegin\"];\n\nfn valid_key_code(tok: &str) -> bool {\n    KEY_NAMES.contains(&tok)\n        || tok.chars().count() == 1\n        || (tok.starts_with('F') && (1..=24).contains(&tok[1..].parse::<u8>().unwrap_or(0)))\n}","typeGuard":"fn parse_key_code(tok: &str) -> Option<crossterm::event::KeyCode> {\n    KeyEvent::from_str(&format!(\"{tok}\")).ok().map(|ev| ev.code)\n}","tryCatchPattern":"let ev = spec.parse::<KeyEvent>()\n    .map_err(|e| anyhow!(\"keymap entry '{spec}': {e} — see helix-view/src/input.rs keys module for names\"))?;","preventionTips":["Use Helix's short names: ret, esc, del, ins, space, not return/escape/delete/insert.","Lint keymaps by parsing every key string at config load.","Avoid trailing whitespace and smart quotes when editing config files."],"tags":["keymap","input","helix","rust"],"backgroundTag":null,"analyzedSha":"079a789e8cb08ead67f19e1971a1b7438b37354b","analyzedAt":"2026-08-16T09:09:59.668Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}