Fix kitty keyboard "Report event types" behavior not matching spec

According to spec:
- The Enter, Tab and Backspace keys will not have release events unless
  "Report all keys as escape codes" is also set.
- Key events that result in text are reported as plain UTF-8 text, so
  events are not supported for them, unless the application requests
  "key report" mode.

I checked kitty's behavior. While it does report release events for keys
that result in text as CSI sequences, press and repeat events for these
are reported as plain UTF-8 text. This commit changes Xterm.js to match
this behavior.
This commit is contained in:
zeertzjq
2026-05-11 13:59:01 +08:00
parent 6ba731d73b
commit b0f5bc2d28
2 changed files with 119 additions and 5 deletions
+6 -1
View File
@@ -477,7 +477,12 @@ export class KittyKeyboard {
if (flags & KittyKeyboardFlags.REPORT_ALL_KEYS_AS_ESCAPE_CODES) {
useCsiU = true;
} else if (reportEventTypes) {
} else if (reportEventTypes && eventType === KittyKeyboardEventType.RELEASE) {
// Per spec, Enter/Tab/Backspace will not have release events unless "Report all keys as
// escape codes" (which is handled by the branch above) is also set.
if (keyCode === 13 || keyCode === 9 || keyCode === 127) {
return result;
}
useCsiU = true;
} else if (flags & KittyKeyboardFlags.DISAMBIGUATE_ESCAPE_CODES) {
// Per spec, Enter/Tab/Backspace "still generate the same bytes as in legacy