{"record":{"id":"10b6f8b818452324","repo":"moeru-ai/airi","slug":"invalid-accelerator-unknown-key-token","errorCode":null,"errorMessage":"Invalid accelerator: unknown key \"${token}\"","messagePattern":"Invalid accelerator: unknown key \"(.+?)\"","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/stage-shared/src/global-shortcut/accelerators.ts","lineNumber":270,"sourceCode":"    return token\n\n  const aliased = KEY_ALIASES.get(token)\n  if (aliased !== undefined)\n    return aliased\n\n  if (SINGLE_LETTER_RE.test(token)) {\n    const candidate = `Key${token.toUpperCase()}`\n    if (LETTER_KEYS.has(candidate))\n      return candidate\n  }\n\n  if (SINGLE_DIGIT_RE.test(token)) {\n    const candidate = `Digit${token}`\n    if (DIGIT_KEYS.has(candidate))\n      return candidate\n  }\n\n  throw new Error(`Invalid accelerator: unknown key \"${token}\"`)\n}\n\n/**\n * Returns the canonical modifier for a token, or `undefined` if the\n * token is not a modifier (i.e. probably a key).\n */\nfunction lookupModifierToken(token: string): ShortcutModifier | undefined {\n  return MODIFIER_ALIASES.get(token.toLowerCase())\n}\n\n/**\n * Parses a string accelerator into its canonical structured form.\n *\n * Use when:\n * - Accepting an accelerator from author code, settings UI, or config\n *   file\n * - Validating user input\n *","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/stage-shared/src/global-shortcut/accelerators.ts#L252-L288","documentation":"normalizeAcceleratorToken (packages/stage-shared/src/global-shortcut/accelerators.ts:270) maps an accelerator token to a canonical ShortcutKey: it checks named key aliases (F-keys, arrows, etc.), then single letters (Key + uppercase) and single digits (Digit + n). If every lookup misses, this error is thrown: the token is not any known key name or alias.","triggerScenarios":"Calling parseAccelerator with an unsupported key such as 'PrtSc', 'Space' (if not in the alias map), 'F13+', or a typo like 'KyK' or 'Commad+K'. Note '+' is the separator, so it can never itself be a token.","commonSituations":"User-configurable shortcut strings from settings files or stored profiles, cross-platform shortcuts copied from other apps whose key names (e.g. 'PrintScreen', 'NUM0') differ from this library's aliases.","solutions":["Use canonical names/aliases the library knows: 'A'-'Z', '0'-'9', or the named keys defined in the alias map (e.g. 'ArrowUp', 'F1'-'F12', 'Escape')","Print ShortcutKey / MODIFIER_ALIASES keys from the module to see accepted tokens for your version","Wrap parseAccelerator in try/catch when input comes from users, and reject with a validation message"],"exampleFix":"// before\nparseAccelerator('Mod+Shift+PrtSc') // throws: unknown key\n// after\nparseAccelerator('Mod+Shift+P')","handlingStrategy":"validation","validationCode":"const KEY_TOKEN_RE = /^(F([1-9]|1[0-2])|Arrow(Up|Down|Left|Right)|Escape|Enter|Tab|Backspace|Delete|Space|[A-Z]|[0-9])$/i\n\nfunction isValidKeyToken(token: string): boolean {\n  return KEY_TOKEN_RE.test(token)\n}","typeGuard":"function isParsableAccelerator(input: string): boolean {\n  if (input.trim().length === 0) return false\n  return input.split('+').every(raw => {\n    const token = raw.trim()\n    return token.length > 0 && (lookupModifierToken(token) !== undefined || KEY_TOKEN_RE.test(token))\n  })\n}","tryCatchPattern":"try {\n  registerGlobalShortcut(parseAccelerator(userShortcut), handler)\n}\ncatch (error) {\n  if (error instanceof Error && error.message.startsWith('Invalid accelerator')) {\n    markShortcutInvalid(userShortcut) // surface a validation error to the user\n    return\n  }\n  throw error\n}","preventionTips":["Restrict shortcut inputs to the alias set the library supports (letters, digits, F1-F12, arrows, named keys)","Validate user-entered hotkeys before persisting them","Test cross-platform shortcuts against this library's alias list, not other apps' spellings"],"tags":["keyboard","shortcut","accelerator","validation","stage-shared"],"backgroundTag":"invalid-keyboard-accelerator","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","contentChangedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}