feat: add arrow keys, shift+tab, home/end/delete/pageup/pagedown to sendNamedKey (#1920)

The socket API's send-key command only supported enter, escape, tab,
backspace, and ctrl+letter. Arrow keys and shift+tab had to be sent
as raw escape sequences via send_text, but 0x1B is filtered out by
socketTextChunks and converted to a standalone Escape key event,
breaking multi-byte sequences like \x1b[A (ArrowUp).

This commit extends sendNamedKey to handle:
- Arrow keys: up/down/left/right (with arrow_up/arrowup aliases)
- shift+tab / shift-tab / backtab
- home, end
- delete / del / forward_delete
- pageup / page_up
- pagedown / page_down

These map directly to the existing sendKeyEvent infrastructure using
the appropriate kVK_* keycodes and modifier flags.

Co-authored-by: I Luk Kim <yirugi@gmail.com>
This commit is contained in:
I LUK KIM 2026-03-24 23:58:51 -07:00 committed by GitHub
parent 71828fe86e
commit 533699f98c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -13205,6 +13205,36 @@ class TerminalController {
case "backspace":
sendKeyEvent(surface: surface, keycode: UInt32(kVK_Delete))
return true
case "up", "arrow_up", "arrowup":
sendKeyEvent(surface: surface, keycode: UInt32(kVK_UpArrow))
return true
case "down", "arrow_down", "arrowdown":
sendKeyEvent(surface: surface, keycode: UInt32(kVK_DownArrow))
return true
case "left", "arrow_left", "arrowleft":
sendKeyEvent(surface: surface, keycode: UInt32(kVK_LeftArrow))
return true
case "right", "arrow_right", "arrowright":
sendKeyEvent(surface: surface, keycode: UInt32(kVK_RightArrow))
return true
case "shift+tab", "shift-tab", "backtab":
sendKeyEvent(surface: surface, keycode: UInt32(kVK_Tab), mods: GHOSTTY_MODS_SHIFT)
return true
case "home":
sendKeyEvent(surface: surface, keycode: UInt32(kVK_Home))
return true
case "end":
sendKeyEvent(surface: surface, keycode: UInt32(kVK_End))
return true
case "delete", "del", "forward_delete":
sendKeyEvent(surface: surface, keycode: UInt32(kVK_ForwardDelete))
return true
case "pageup", "page_up":
sendKeyEvent(surface: surface, keycode: UInt32(kVK_PageUp))
return true
case "pagedown", "page_down":
sendKeyEvent(surface: surface, keycode: UInt32(kVK_PageDown))
return true
default:
if keyName.lowercased().hasPrefix("ctrl-") || keyName.lowercased().hasPrefix("ctrl+") {
let letter = keyName.dropFirst(5)