Skip to content

feat(tui): enables the kitty keyboard-protocol and enable support for uppercase keybindings#1030

Open
delafthi wants to merge 2 commits intoalexpasmantier:mainfrom
delafthi:delafthi/mpmkopuykksy
Open

feat(tui): enables the kitty keyboard-protocol and enable support for uppercase keybindings#1030
delafthi wants to merge 2 commits intoalexpasmantier:mainfrom
delafthi:delafthi/mpmkopuykksy

Conversation

@delafthi
Copy link
Copy Markdown
Contributor

@delafthi delafthi commented Apr 9, 2026

📺 PR Description

This PR checks if the terminal supports the kitty keyboard protocol and enables it if supported. It also adds support for defining uppercase bindings, such as Ctrl-D or Ctrl-Shift-d.

However, on terminals that don't support the kitty keyboard protocol (like tmux; let's hope tmux PR #4912 gets merged), the shift key information is not propagated to tv. This means that if bindings for both ctrl-d and Ctrl-D are defined, only the ctrl-d action will be executed, since the shifted binding cannot be distinguished from the unshifted one.

The feature was tested in Ghostty.

Checklist

  • my commits and PR title follow the conventional commits format
  • if this is a new feature, I have added tests to consolidate the feature and prevent regressions
  • if this is a bug fix, I have added a test that reproduces the bug (if applicable)
  • I have added a reasonable amount of documentation to the code where appropriate

Resolves #966

Comment thread television/event.rs
Comment on lines +383 to +395
Char(c) => {
let c = if event.modifiers.contains(KeyModifiers::SHIFT) {
c.to_uppercase().next().unwrap_or(c)
} else {
c
};
match event.modifiers - KeyModifiers::SHIFT {
KeyModifiers::NONE => Key::Char(c),
KeyModifiers::CONTROL => Key::Ctrl(c),
KeyModifiers::ALT => Key::Alt(c),
_ => Key::Null,
}
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a shifted key is pressed, it is reported as:

2026-04-09T20:48:46.857697Z TRACE television/event.rs:328: Raw event: KeyEvent { code: Char('d'), modifiers: KeyModifiers(SHIFT | CONTROL), kind: Press, state: KeyEventState(0x0) }

Here the shift modifier is first applied to the character, then the other modifiers are processed. This ensures that shifted keys work correctly on characters with all currently supported modifiers.

@delafthi delafthi force-pushed the delafthi/mpmkopuykksy branch 4 times, most recently from 3d28ced to 12e27d7 Compare April 9, 2026 21:27
@delafthi
Copy link
Copy Markdown
Contributor Author

delafthi commented Apr 9, 2026

I'm struggling with the tests. I'm not sure why some of them are breaking. Probably, because some of them have timing issue due to the additional check for kitty keyboard protocol support.

@alexpasmantier alexpasmantier force-pushed the delafthi/mpmkopuykksy branch from 12e27d7 to 5ee5c39 Compare April 14, 2026 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Control + upper case keybindings

1 participant