Server.writeKeyToPty drops modifiers on .arrow, .special, and .function keys and hardcodes DECCKMpane.screen.mode.keypadSeverity: CRITICAL
Status: ✅ RESOLVED
Files: src/server/server.zig:1324-1365
When an inner application has not enabled the Kitty keyboard protocol (pane.screen.mode.kitty_kbd == 0 — the default for shells, vim, less, emacs, readline/zsh), Server.writeKeyToPty encodes keys via src/server/server.zig:1324-1365:
.arrow => |a| {
const seq = switch (a.dir) {
.up => "\x1bOA",
.down => "\x1bOB",
.right => "\x1bOC",
.left => "\x1bOD",
};
pty.writeInput(seq) catch ...;
},
.special => |s| {
const seq = switch (s.key) {
.enter => "\r",
.tab => "\t",
...
This has two major defects:
a.mod, s.mod, f.mod) are silently dropped:
Ctrl+Left / Ctrl+Right, Alt+Left / Alt+Right, Shift+Arrow (\x1b[1;{mod}A..D) are sent as plain unmodified arrows.Shift+Tab (\x1b[Z), Alt+Enter (\x1b\r), Alt+Backspace (\x1b\x7f), Ctrl+Delete / Shift+Delete (\x1b[3;{mod}~), Shift+Home/End, and modified F1..F12 all lose their modifiers.src/server/server.zig:1255-1301 contains a dead switch (ch.code) for Kitty Private Use Area codepoints 57344..57353 and ch.code == 9 inside the .char => |ch| arm, which is never reached because key.parseCsi (src/key.zig:196-206) and key.parseSingleByte (src/key.zig:350) already decode those keys into .special and .arrow.\x1bOA..\x1bOD) is hardcoded for unmodified arrows:
Unmodified arrow keys always emit \x1bOA..\x1bOD (SS3, valid only when DECCKM / pane.screen.mode.keypad is true) instead of \x1b[A..\x1b[D (CSI) when pane.screen.mode.keypad is false.Server.writeKeyToPty’s .arrow arm:
a.mod.toInt() != 0, emit \x1b[1;{mod_param}{A|B|C|D} where mod_param = 1 + a.mod.toInt().\x1bOA..\x1bOD if pane.screen.mode.keypad is true, and \x1b[A..\x1b[D if false..special and .function:
\x1b[Z for Shift+Tab, \x1b prefix for Alt+Enter/Alt+Backspace/Alt+Tab, \x1b[1;{mod}{H|F|P|Q|R|S} for modified Home/End/F1..F4, and \x1b[{code};{mod}~ for modified tilde keys (Insert, Delete, PageUp, PageDown, F5..F12), or honor pane.screen.extkeys (modifyOtherKeys) for modified Enter/Tab/Backspace.57344..57353 and ch.code == 9 branches from .char.