MCPcopy Index your code
hub / github.com/codeaashu/claude-code / keycodeToName

Function keycodeToName

src/ink/parse-keypress.ts:487–541  ·  view source on GitHub ↗

* Map keycode to key name for modifyOtherKeys/CSI u sequences. * Handles both ASCII keycodes and Kitty keyboard protocol functional keys. * * Numpad codepoints are from Unicode Private Use Area, defined at: * https://sw.kovidgoyal.net/kitty/keyboard-protocol/#functional-key-definitions

(keycode: number)

Source from the content-addressed store, hash-verified

485 * https://sw.kovidgoyal.net/kitty/keyboard-protocol/#functional-key-definitions
486 */
487function keycodeToName(keycode: number): string | undefined {
488 switch (keycode) {
489 case 9:
490 return 'tab'
491 case 13:
492 return 'return'
493 case 27:
494 return 'escape'
495 case 32:
496 return 'space'
497 case 127:
498 return 'backspace'
499 // Kitty keyboard protocol numpad keys (KP_0 through KP_9)
500 case 57399:
501 return '0'
502 case 57400:
503 return '1'
504 case 57401:
505 return '2'
506 case 57402:
507 return '3'
508 case 57403:
509 return '4'
510 case 57404:
511 return '5'
512 case 57405:
513 return '6'
514 case 57406:
515 return '7'
516 case 57407:
517 return '8'
518 case 57408:
519 return '9'
520 case 57409: // KP_DECIMAL
521 return '.'
522 case 57410: // KP_DIVIDE
523 return '/'
524 case 57411: // KP_MULTIPLY
525 return '*'
526 case 57412: // KP_SUBTRACT
527 return '-'
528 case 57413: // KP_ADD
529 return '+'
530 case 57414: // KP_ENTER
531 return 'return'
532 case 57415: // KP_EQUAL
533 return '='
534 default:
535 // Printable ASCII characters
536 if (keycode >= 32 && keycode <= 126) {
537 return String.fromCharCode(keycode).toLowerCase()
538 }
539 return undefined
540 }
541}
542
543export type ParsedKey = {
544 kind: 'key'

Callers 1

parseKeypressFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected