MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / keycodeToName

Function keycodeToName

source code/ink/parse-keypress.ts:489–543  ·  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

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

Callers 1

parseKeypressFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected