{"record":{"id":"83d6477e0e3c3f6b","repo":"can1357/oh-my-pi","slug":"unknown-key-rest","errorCode":null,"errorMessage":"unknown key ${rest}","messagePattern":"unknown key (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/tui/src/debug-server.ts","lineNumber":147,"sourceCode":"\t\trest = rest.slice(2);\n\t}\n\tif (/^S-/i.test(rest)) {\n\t\tshift = true;\n\t\trest = rest.slice(2);\n\t}\n\tif (rest.length === 0 || /^(?:C-|A-|M-|S-)/i.test(rest)) throw new Error(`invalid key token ${token}`);\n\n\tconst name = rest.toLowerCase();\n\tconst special = SPECIAL_KEYS[name];\n\tif (special !== undefined) {\n\t\tif (ctrl && name === \"space\") return alt ? \"\\x1b\\x00\" : \"\\x00\";\n\t\tif (ctrl && name === \"backspace\") return alt ? \"\\x1b\\x08\" : \"\\x08\";\n\t\tconst modifier = 1 + (shift ? 1 : 0) + (alt ? 2 : 0) + (ctrl ? 4 : 0);\n\t\tlet encoded = modifiedSpecial(special, modifier);\n\t\tif (alt && encoded === special) encoded = `\\x1b${encoded}`;\n\t\treturn encoded;\n\t}\n\tif (Array.from(rest).length !== 1) throw new Error(`unknown key ${rest}`);\n\tlet character = rest;\n\tif (shift && /^[a-z]$/i.test(character)) character = character.toUpperCase();\n\tif (ctrl) character = ctrlCharacter(character);\n\treturn alt ? `\\x1b${character}` : character;\n}\n\nfunction parseKeyTokens(source: string): { sequences: string[]; events: number } {\n\tlet offset = 0;\n\tconst sequences: string[] = [];\n\tlet events = 0;\n\twhile (offset < source.length) {\n\t\twhile (/\\s/.test(source[offset] ?? \"\")) offset++;\n\t\tif (offset >= source.length) break;\n\t\tconst quote = source[offset];\n\t\tif (quote === \"'\" || quote === '\"') {\n\t\t\toffset++;\n\t\t\tlet literal = \"\";\n\t\t\twhile (offset < source.length && source[offset] !== quote) {","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/tui/src/debug-server.ts#L129-L165","documentation":"encodeChord() accepts either a SPECIAL_KEYS name or a single character as the base key. If the remaining token (after modifiers) is neither — e.g. multi-character words not in the table — it throws `unknown key ${rest}`.","triggerScenarios":"Tokens like \"foo\", \"enter-key\", \"page-up\" if not present in SPECIAL_KEYS, or multi-char literals passed as bare tokens instead of quoted literals.","commonSituations":"Misspelled special key names (\"backspace\" vs \"backpace\"); using platform-specific key names not in SPECIAL_KEYS; forgetting to quote literal strings in the key sequence.","solutions":["Use a key name listed in SPECIAL_KEYS (e.g. \"enter\", \"tab\", \"escape\")","For literal text, use the quoted-literal syntax of the key sequence parser","Fix typos in the key name"],"exampleFix":"// before\nencodeChord(\"pageup\") // if not in SPECIAL_KEYS\n// after\nencodeChord(\"page-up\") // or the exact SPECIAL_KEYS spelling","handlingStrategy":"validation","validationCode":"function isKnownKey(name: string): boolean {\n  return name.length === 1 || name.toLowerCase() in SPECIAL_KEYS;\n}","typeGuard":null,"tryCatchPattern":"try {\n  seq = encodeChord(token);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"unknown key\")) {\n    logger.warn(\"unknown key name\", { token });\n    continue;\n  }\n  throw err;\n}","preventionTips":["Consult SPECIAL_KEYS for exact key spellings before writing sequences","Quote multi-character literals instead of passing them as bare tokens","Add a smoke test that encodes every key name your scripts use"],"tags":["keyboard-input","parsing","debug"],"backgroundTag":"invalid-key-sequence","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}