{"record":{"id":"e1a32eae646143c1","repo":"Mintplex-Labs/anything-llm","slug":"key-requires-key-argument-e-g-enter-tab-esca","errorCode":null,"errorMessage":"key requires <key> argument (e.g. Enter, Tab, Escape)","messagePattern":"key requires <key> argument \\(e\\.g\\. Enter, Tab, Escape\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"open-computer/services/interface-service/utils/cdp-input.js","lineNumber":175,"sourceCode":"          key: char,\n          code: charToCode(char),\n          unmodifiedText: char,\n        }, sessionId);\n\n        await cdpSend(ws, \"Input.dispatchKeyEvent\", {\n          type: \"keyUp\",\n          key: char,\n          code: charToCode(char),\n        }, sessionId);\n\n        await sleep(keystrokeDelay());\n      }\n\n      process.stdout.write(`typed ${text.length} chars`);\n\n    } else if (action === \"key\") {\n      const key = process.argv[3];\n      if (!key) throw new Error(\"key requires <key> argument (e.g. Enter, Tab, Escape)\");\n\n      const keyDef = specialKeys[key] || { key, code: `Key${key.toUpperCase()}` };\n\n      await cdpSend(ws, \"Input.dispatchKeyEvent\", {\n        type: \"keyDown\",\n        key: keyDef.key,\n        code: keyDef.code,\n        windowsVirtualKeyCode: keyDef.keyCode || 0,\n        nativeVirtualKeyCode: keyDef.keyCode || 0,\n      }, sessionId);\n      await sleep(50);\n\n      await cdpSend(ws, \"Input.dispatchKeyEvent\", {\n        type: \"keyUp\",\n        key: keyDef.key,\n        code: keyDef.code,\n        windowsVirtualKeyCode: keyDef.keyCode || 0,\n        nativeVirtualKeyCode: keyDef.keyCode || 0,","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/open-computer/services/interface-service/utils/cdp-input.js#L157-L193","documentation":"cdp-input argument validation for action 'key': argv[3] must be a non-empty key name; it is looked up in the specialKeys table (Enter, Tab, Escape, etc.) and otherwise synthesized as key `Key${uppercase}` with code for Input.dispatchKeyEvent keyDown/keyUp. Missing/empty key aborts before dispatch.","triggerScenarios":"Running `node cdp-input.js key` with no argument; passing an unquoted empty shell variable; passing the tab filter but forgetting the key itself.","commonSituations":"Automated presses built from variables that are undefined; users assuming 'key' with no arg presses Enter; casing/spacing mistakes that still pass validation but produce a wrong code (e.g. 'KeyENTER' -> 'KeyKEYENTER').","solutions":["Pass a recognized key name: node cdp-input.js key Enter [tabFilter] (Enter, Tab, Escape, Backspace, etc.)","Quote arguments from variables in calling scripts and default sensibly: \"${KEY:-Enter}\"","For single printable characters use the type action instead of key"],"exampleFix":"# before\nnode cdp-input.js key            # missing key name\n# after\nnode cdp-input.js key Enter\n# scripted:\nnode cdp-input.js key \"${KEY_NAME:-Enter}\"","handlingStrategy":"validation","validationCode":"const KEY = process.argv[3];\nconst KNOWN = new Set(['Enter','Tab','Escape','Backspace','Delete','ArrowUp','ArrowDown','ArrowLeft','ArrowRight','Home','End','PageUp','PageDown']);\nif (!KEY || KEY.length === 0) { console.error('usage: cdp-input.js key <key> [tabFilter]'); process.exit(2); }\nif (!KNOWN.has(KEY)) console.warn(`unrecognized key '${KEY}' — synthesized as Key${KEY.toUpperCase()}`);","typeGuard":"function isSpecialKey(k: unknown): k is 'Enter'|'Tab'|'Escape'|'Backspace' { return ['Enter','Tab','Escape','Backspace'].includes(k as string); }","tryCatchPattern":"try { await sendInput('key', keyName); } catch (e) { if (/key requires <key> argument/.test(e.message)) { /* caller bug: supply the key name */ } else throw e; }","preventionTips":["Pass canonical key names exactly as CDP expects them (Enter, Tab, Escape) — case matters for the synthesized code","Default sensibly in scripts: `node cdp-input.js key \"${KEY:-Enter}\"`","For printable characters prefer the type action; key is for named/non-printable keys"],"tags":["chrome","cdp","keyboard","cli-args","validation","open-computer"],"backgroundTag":"invalid-cli-argument","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}