Skip to content

Parse Kitty Keyboard Protocol esc codes to suport Ctrl-Shift-<Key> shortcuts#887

Open
UnnaturalTwilight wants to merge 3 commits into
microsoft:mainfrom
UnnaturalTwilight:fix/CSI-u-inputs
Open

Parse Kitty Keyboard Protocol esc codes to suport Ctrl-Shift-<Key> shortcuts#887
UnnaturalTwilight wants to merge 3 commits into
microsoft:mainfrom
UnnaturalTwilight:fix/CSI-u-inputs

Conversation

@UnnaturalTwilight

Copy link
Copy Markdown
Contributor

Adds parsing for the most basic form of Kitty keyboard events. This fixes the existing Ctrl-Shift-z shortcut for redo when using a terminal that implements the kitty keyboard protocol. I have also add Ctrl-Shift-c as an additional shortcut for copy since that is often used in terminals.

Not a full implementation but solves some of: #29

I have tested this in Kitty on linux and in Windows Terminal through WSL.
I have only tested this with an en-us qwerty keyboard layout.

@UnnaturalTwilight

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

@lhecker lhecker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

...but you aren't enabling the Kitty Keyboard Protocol on startup?

@UnnaturalTwilight

Copy link
Copy Markdown
Contributor Author

Per the spec, any key sequence that can't be represented without the Kitty Keyboard Protocol is sent using it regardless if it is requested. I was trying to avoid affecting any of the current parsing logic but if you think it is better to enable it I can add that.
https://sw.kovidgoyal.net/kitty/keyboard-protocol/#:~:text=Any%20key,enhancement

@lhecker

lhecker commented Jul 21, 2026

Copy link
Copy Markdown
Member

Since nothing is using Ctrl-Shift combinations yet we can take our time to do this properly: Implement a full Kitty Keyboard Protocol integration. One of the problems here is that this PR is using from_ascii but the protocol does not limit the key code to ASCII.

this is needed to parse ctrl+shift+<a...z> and other unprintable modifier combos
I have only tested this with en-us querty and it may have weird behavor with non latin layouts due to casting the codepoint to u8
@UnnaturalTwilight

Copy link
Copy Markdown
Contributor Author

I have now done a more complete implementation of the first level of progressive enhancement for the protocol. I don't think higher levels of enhancement are necessary for what edit dose.

I was not able to find a relevant vk constant for numpad equals which is why it stands out in the list.
I also couldn't find an applicable vk constant for the menu key which is the only one of the keys that are currently ignored that I think may make sense to add key a keybinding to.

I have also now tested this with a french keyboard layout to confirm that non-ascii characters work properly.

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.

2 participants