feat(tui): enables the kitty keyboard-protocol and enable support for uppercase keybindings - #1030
feat(tui): enables the kitty keyboard-protocol and enable support for uppercase keybindings#1030delafthi wants to merge 2 commits into
Conversation
| 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, | ||
| } | ||
| } |
There was a problem hiding this comment.
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.
3d28ced to
12e27d7
Compare
|
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. |
12e27d7 to
5ee5c39
Compare
|
@alexpasmantier, should I keep this ready for merging? This is just a basic implementation, and I opened the pull request to gather some feedback. I haven’t spent much time figuring out why the tests are failing and thought you could point me into the right direction. If you’re interested, you can also ping me to update this PR when you believe this feature is ready to be merged. |
|
Just been really busy these past weeks, sorry about that. |
No pressure 😉 |
📺 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-DorCtrl-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 bothctrl-dandCtrl-Dare defined, only thectrl-daction will be executed, since the shifted binding cannot be distinguished from the unshifted one.The feature was tested in Ghostty.
Checklist
Resolves #966