Implement "report alternate keys" from the Kitty Keyboard Protocol #754
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The "report alternate keys" part of the Kitty keyboard protocol will send an additional codepoint containing the "shifted" version of a key based on the keyboard layout. This is useful for downstream applications which set up keybindings based on symbols instead of exact keys being pressed.
For example, underscore (_) with the Alt modifier is sent as minus (-) with Alt and Shift modifiers. A terminal will send the underscore codepoint as an alternate though, and we can use that information and the presence of the Shift modifier to resolve the symbol. Other examples are
A-(
(sent asA-S-9
) andA-)
(sent asA-S-0
).This change allows pushing the "report alternate keys" flag and overwrites the keycode and modifiers for any shifted keys sent by the terminal.
This alternate key handling is the same as Kakoune's: https://github.com/mawww/kakoune/blob/eb0e9831330d3b1e1d3ddb2bc789000706e6e445/src/terminal_ui.cc#L804-L813