{"record":{"id":"63631cb87bf04f4c","repo":"Hmbown/CodeWhale","slug":"unknown-key-p-supported-object-keys-key-codes-join-modifiers","errorCode":null,"errorMessage":"unknown key \"${p}\" (supported: ${Object.keys(KEY_CODES).join(\", \")} + modifiers cmd/ctrl/alt/shift/fn)","messagePattern":"unknown key \"(.+?)\" \\(supported: (.+?) \\+ modifiers cmd/ctrl/alt/shift/fn\\)","errorType":"exception","errorClass":"ExecError","httpStatus":null,"severity":"error","filePath":"crates/tui/plugins/computer-use/src/backends/darwin.mjs","lineNumber":493,"sourceCode":"    try {\n      await action();\n      // The acknowledgement carries the yield_ms the helper waited for a\n      // hardware-input gap before posting the press.\n      return lease.receipt;\n    } finally {\n      await withSignal(null, () => lease.release());\n    }\n  }\n\n  function parseChord(text) {\n    const parts = String(text).split(\"+\").map((s) => s.trim().toLowerCase()).filter(Boolean);\n    if (!parts.length) throw new ExecError(\"empty key text\");\n    let flags = 0;\n    let key = null;\n    for (const p of parts) {\n      if (MODIFIERS[p] != null) flags |= MODIFIERS[p];\n      else if (KEY_CODES[p] != null) { if (key) throw new ExecError(`multiple non-modifier keys in \"${text}\"`); key = p; }\n      else throw new ExecError(`unknown key \"${p}\" (supported: ${Object.keys(KEY_CODES).join(\", \")} + modifiers cmd/ctrl/alt/shift/fn)`);\n    }\n    if (key == null) throw new ExecError(`no non-modifier key in \"${text}\"`);\n    return { flags, code: KEY_CODES[key], key };\n  }\n\n  // ---------- displays ----------\n  async function displayInfo() { return native(\"displays\"); }\n\n  // ---------- screenshots ----------\n  function recordingsDir() {\n    return process.env.CODEWHALE_CU_RECORDINGS_DIR || path.join(os.homedir(), \".codewhale-cu\", \"recordings\");\n  }\n\n  async function screenshot({ display, region, app_ref, window_id, path: outPath } = {}) {\n    // Once an app is selected, ordinary observations follow it behind the\n    // user's work. An explicit display/region remains a deliberate desktop capture.\n    if (app_ref === undefined && display === undefined && region === undefined) app_ref = state.inputApp ?? undefined;\n    const dir = recordingsDir();","sourceCodeStart":475,"sourceCodeEnd":511,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/plugins/computer-use/src/backends/darwin.mjs#L475-L511","documentation":"Every '+'-separated token must be either a known modifier (cmd/ctrl/alt/shift/fn) or a key in the backend's KEY_CODES table. Any unrecognized token is rejected, and the message enumerates the supported key names so the caller can correct it.","triggerScenarios":"Passing key names not in KEY_CODES, e.g. 'win', 'meta', 'return' (if table uses 'enter'), 'spacebar', 'esc' vs 'escape', uppercase (input is lowercased, so this is safe), or accented/symbol characters.","commonSituations":"Cross-platform key naming habits (Windows key names on macOS backend); typos like 'cmnd'; assuming alias coverage the table does not have.","solutions":["Use a key name from the supported list printed in the error message","Map platform aliases before calling: 'win'/'meta' -> 'cmd', 'esc' -> 'escape' if that is the table's name","Extend/consult the KEY_CODES table for the exact accepted names","Trim and lowercase input (parseChord already lowercases, so fix spelling rather than case)"],"exampleFix":"// before\nawait press(\"win+c\");\n// after\nawait press(\"cmd+c\");","handlingStrategy":"validation","validationCode":"const ALIAS = { win: \"cmd\", meta: \"cmd\", super: \"cmd\", esc: \"escape\", return: \"enter\" };\nconst normalized = key.split(\"+\").map(p => ALIAS[p.trim().toLowerCase()] ?? p.trim().toLowerCase()).join(\"+\");","typeGuard":null,"tryCatchPattern":"try {\n  await press(key);\n} catch (e) {\n  if (e instanceof ExecError && e.message.startsWith(\"unknown key\")) {\n    const supported = e.message.match(/supported: ([^+]+)/)?.[1];\n    throw new Error(`key '${key}' unsupported; use one of: ${supported}`);\n  }\n  throw e;\n}","preventionTips":["Keep an alias map from Windows/web key names to macOS backend names","Validate against the KEY_CODES list (printed in the error) at your boundary","Prefer lowercase canonical names from the backend's documentation"],"tags":["keyboard","unknown-key","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T11:17:16.035Z"}