Skip to content

Commit 1ea78f2

Browse files
Fix detection of Shift + Enter in integrated terminal (#103)
1 parent 9b77cb3 commit 1ea78f2

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/input/keyboard.zig

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,14 @@ fn parseControl(c: u8) KeyEvent {
8383
return switch (c) {
8484
0 => .{ .key = .null_key, .modifiers = .{ .ctrl = true } },
8585
9 => .{ .key = .tab },
86-
10, 13 => .{ .key = .enter },
86+
// In raw mode 0x0a is sent by the terminal itself
87+
// Some editor-integrated terminals (Zed, possibly VSCode) use this
88+
// historical CR/LF split to encode Shift+Enter without a richer
89+
// keyboard protocol -- plain Enter sends 0x0d, Shift+Enter sends
90+
// 0x0a. Mapping LF onto Enter+Shift recovers the modifier, ensuring
91+
// consistent behavior to other TUI applications / libraries.
92+
10 => .{ .key = .enter, .modifiers = .{ .shift = true } },
93+
13 => .{ .key = .enter },
8794
27 => .{ .key = .escape },
8895
1...8, 11, 12, 14...26 => .{
8996
.key = .{ .char = 'a' + c - 1 },

0 commit comments

Comments
 (0)