ghostty
ghostty copied to clipboard
kitty keyboard protocol: AltGr+plus should produce a tilde, but produces a plus instead
On Linux with the DE keyboard layout the AltGr modifier is interpreted differently in Ghostty to Kitty.
Here is kitty's interpretation:
ENTER RELEASE
CSI 13 ; 1 : 3 u
ISO_LEVEL3_SHIFT PRESS
CSI 57453 u
~ PRESS ~
CSI 126 : : 93 ; ; 126 u
Alternate key: ]
~ RELEASE
CSI 126 : : 93 ; 1 : 3 u
Alternate key: ]
ISO_LEVEL3_SHIFT RELEASE
CSI 57453 ; 1 : 3 u
And here is Ghostty:
ENTER RELEASE
CSI 13 ; 1 : 3 u
RIGHT_ALT PRESS
CSI 57449 u
+ PRESS ~
CSI 43 ; ; 126 u
+ RELEASE
CSI 43 ; 1 : 3 u
RIGHT_ALT RELEASE
CSI 57449 ; 1 : 3 u
Foot is a little different, but much closer to kitty:
ENTER RELEASE
CSI 13 ; 1 : 3 u
ISO_LEVEL3_SHIFT PRESS
CSI 57453 ; 1 : 1 u
~ PRESS ~
CSI 126 : : 43 ; 1 : 1 ; 126 u
Alternate key: +
~ RELEASE
CSI 126 : : 43 ; 1 : 3 u
Alternate key: +
ISO_LEVEL3_SHIFT RELEASE
CSI 57453 ; 1 : 3 u
You said foot so I assume this is Linux. The input stacks across operating systems are dramatically different so that's an important detail. Can you confirm?
Also, can you share perhaps a picture of the keyboard layout and exactly which key you're pressing?
Yes, Linux.
On the german keyboard layout AltGr is the regular right Alt key and + is the key two keys to the right of P. It's ] (left square bracket) on a US keyboard.
Note: This behavior applies to all AltGr (aka ISO_LEVEL3_SHIFT) modified key presses. It's not just ~.
This shows all the AltGr modifyable keys on a german keyboard. They are the lower right symbols.
As a note, here is macOS with a German standard layout, which is completely different and Ghostty does much better here (but still not 100% correct).
Kitty
alt+RIGHT_ALT PRESS
CSI 57449 ; 3 u
alt++ PRESS ~
CSI 43 : : 93 ; 3 ; 126 u
Alternate key: ]
alt++ RELEASE
CSI 43 : : 93 ; 3 : 3 u
Alternate key: ]
RIGHT_ALT RELEASE
CSI 57449 ; 1 : 3 u
Ghostty
alt+RIGHT_ALT PRESS
CSI 57449 ; 3 u
alt++ PRESS ~
CSI 43 ; 3 ; 126 u
alt++ RELEASE
CSI 43 ; 3 : 3 u
RIGHT_ALT RELEASE
CSI 57449 ; 1 : 3 u
Here are the inspector events. Doesn't look like there is any ISO_LEVEL3_SHIFT info, so I guess it's at a lower level?
I've confirmed this with Linux.
This is a bug in the sense that we aren't matching Kitty here (and there is the minor alternate key issue on macOS too). But, I kind of want to open a discussion with Kovid and ask if this is a bug more generally in the Kitty keyboard protocol one way or the other (whether it should match Linux on macOS or vice versa).
One of the benefits of the keyboard protocol is that it tries to avoid the input-stack-specific quirks and provide a cross-platform input layer on top. If there are different key codes being sent for the same logical action on macOS and Linux, that's pretty annoying.
cc @gpanders @rockorager What do you think?
Also, just for notes: I confirmed this isn't related -- on macOS -- to macos_option_as_alt. I didn't think it would be since that has a minimal effect on the Kitty protocol (primarily impacts the legacy protocol) but I just wanted to check to be sure. I verified with Kitty on this.
One of the benefits of the keyboard protocol is that it tries to avoid the input-stack-specific quirks and provide a cross-platform input layer on top. If there are different key codes being sent for the same logical action on macOS and Linux, that's pretty annoying.
+1 to discussing with Kovid. This consistency is important both for terminal developers and for applications.
+1 to discussing with Kovid. This consistency is important both for terminal developers and for applications.
I agree.
If I were to derive the encoding from my understanding of the protocol, the key is '+', the text is '~', and the alternate key is ']'. This would be unmodified because the AltGr was consumed to produce the text (similar to option key in mac).
So it should be CSI 43 : : 93 ; ; 126 u
EDIT: I can see a case for having this as alt-modified.
Thanks. I've posted the problem, without a solution, here: https://github.com/kovidgoyal/kitty/discussions/8126
Kovid is usually pretty quick to respond so I'm going to give that upstream issue some time before attempting to iron out any of the quirks in Ghostty.
Note: The original flow input issue is now resolved. There was a bug in flow's new input system where it was not using the alternative text field correctly.
This means that this issue is now just about a difference in matching keybindings for AltGr modified keys between kitty and ghostty. Still an issue, but way less important as AltGr keys are seldom, if ever, used for key binding.
A similar issue (QWERTZ layout on a German keyboard) reported here https://github.com/neovim/neovim/issues/31045. In this case, C-] (Ctrl + AltGr + 9) is being encoded by Kitty as CSI 93 : : 57 ; 5 u, but in Ghostty as CSI 57 ; 5 u.
I am having a similar problem with this. When I press "~" on ghostty terminal, it waits for me to type a letter to place the tilde, like "ã". But when I type any letter, it just cleans the display. I've noticed it when I was trying to go to my home directory like cd ~/. I pressed ~ and / but it just made a funny sound and kept waiting.
I also can't use any other accentuation character of the Portuguese language in the ghostty terminal. So I can't write words like "amanhã", "vÃdeo" etc. It would be awesome to add support for latin languages. But this doesn't bother me as much as the ~/ thing, cause I use this shortcut a lot on other terminals.
Note: My keyboard has the Brazilian Portuguese layout (ABNT2)
I am having a similar problem with this. When I press "~" on ghostty terminal, it waits for me to type a letter to place the tilde, like "ã". But when I type any letter, it just cleans the display. I've noticed it when I was trying to go to my home directory like cd ~/. I pressed ~ and / but it just made a funny sound and kept waiting.
I also can't use any other accentuation character of the Portuguese language in the ghostty terminal. So I can't write words like "amanhã", "vÃdeo" etc. It would be awesome to add support for latin languages. But this doesn't bother me as much as the ~/ thing, cause I use this shortcut a lot on other terminals.
Note: My keyboard has the Brazilian Portuguese layout (ABNT2)
Same here. I'm not able to type ~ (tilde), ` (backtick) and ^ (circumflex) on my de_CH keyboard. When I type one of those characters, Ghostty (1.1.0-arch) displays it, but pressing space to continue with this character doen't work. The character disappears again.
I am now having trouble typing ^ character in Finnish keyboard. But this happens only when using tmux inside ghostty (ghostty 1.1.0)
I am having a similar problem with this. When I press "~" on ghostty terminal, it waits for me to type a letter to place the tilde, like "ã". But when I type any letter, it just cleans the display. I've noticed it when I was trying to go to my home directory like cd ~/. I pressed ~ and / but it just made a funny sound and kept waiting. I also can't use any other accentuation character of the Portuguese language in the ghostty terminal. So I can't write words like "amanhã", "vÃdeo" etc. It would be awesome to add support for latin languages. But this doesn't bother me as much as the ~/ thing, cause I use this shortcut a lot on other terminals. Note: My keyboard has the Brazilian Portuguese layout (ABNT2)
Same here. I'm not able to type ~ (tilde), ` (backtick) and ^ (circumflex) on my de_CH keyboard. When I type one of those characters, Ghostty (1.1.0-arch) displays it, but pressing space to continue with this character doen't work. The character disappears again.
In my opinion this (tilde, backtick, circumflex) was fixed with 1.1.1-arch.
I am having a similar problem with this. When I press "~" on ghostty terminal, it waits for me to type a letter to place the tilde, like "ã". But when I type any letter, it just cleans the display. I've noticed it when I was trying to go to my home directory like cd ~/. I pressed ~ and / but it just made a funny sound and kept waiting. I also can't use any other accentuation character of the Portuguese language in the ghostty terminal. So I can't write words like "amanhã", "vÃdeo" etc. It would be awesome to add support for latin languages. But this doesn't bother me as much as the ~/ thing, cause I use this shortcut a lot on other terminals. Note: My keyboard has the Brazilian Portuguese layout (ABNT2)
Same here. I'm not able to type ~ (tilde), ` (backtick) and ^ (circumflex) on my de_CH keyboard. When I type one of those characters, Ghostty (1.1.0-arch) displays it, but pressing space to continue with this character doen't work. The character disappears again.
In my opinion this (tilde, backtick, circumflex) was fixed with
1.1.1-arch.
I just updated and everything's working fine now. I can just press tilde twice and it appears on the terminal. The other issues with `, ´, ^ were also fixed. Thanks bro.
Not sure if I'm commenting on the correct issue here .. but I'll give it a try because my issue sounds related and I don't want to unnecessarily open a new issue..
The "full" story of how I got here can be found in https://github.com/tstack/lnav/issues/1411
I am using a non-standard de keyboard layout called neo, which has a lot of characters like brackets etc on a modifier layer, that is accessed by pressing Caps-Lock.
For typing this works well, but in shortcuts, these keys cannot be used (I noticed this when using a shortcut Ctrl-[ which kept dumping me out of the tool I was using, because in neo ] is on the hardware C key on the layer accessed by the Caps-Lock modifier. But since the modifier is ignored when combined with Ctrl this was being transmitted as Ctrl-C .. hence quit the program.
As I mention in the ticket linked above .. I won't pretend to understand this fully, but kitty I think fixed it at some point in time, not totally sure how and when..
These screenshots are from the same exact key sequence being pressed (I use [ instead of ] to avoid Ctrl-Cing out of kitten, so I can take the screenshot :)
Kitty:
Ghostty:
Still an issue, but way less important as AltGr keys are seldom, if ever, used for key binding.
Well, actually AltGr is needed for key bindings for the Swedish (Nordic) keyboard layout for all the default goto_split ones. I believe it is similar for the German keyboard layout, at least for keybinds with [ and ].
I have gone over them all and posted a proposal of a remapping profile here #6740.
As explained there, I haven't been able to find a way to show the need for the AltGr modifier when running ghostty +list-keybinds
Having the same issues here on a Swiss french keyboard layout, where the AltGr key is needed for [ and ]. I also notice other similar problems with the Shift key though, which seems to make other (default) keybinds of ghostty not work.
c-] not captured/working in neovim
I am able to obtain all the keys no problem (i.e [, ], ~, ´, etc....), but issues start when characters require modifiers to be obtained. For example, as mentioned earlier, the c-] mapping in neovim does not seem to work. At first I thought some ghostty keybinds would be interfering, but even after disabling all default bindings, the mapping still does not work. In this case, ghostty gives the following (after I press, Control, AltGR, ¨ to obtain c-]):
Even setting keybind = ctrl+right_bracket=ignore in my config does not seem to make it work in neovim...
Default c-+ to increase font size not working
However, I also notice the default keybind for increasing the font size did not work.
ctrl + plus increase_font_size:1
Here I need to press Shift+1 to obtain a +. Ghostty sees c-+ as as shift+control+plus:
Here, fair enough, after adding keybind = ctrl+shift+plus=increase_font_size:1 to my configuration, I can increase the font size with what should be specified as ctrl+plus.
Default c-s-, for config reload not working
Pressing Shift + , on the swiss layout actually produces a ;. Similar to the ctrl+plus case, here it is recognized as a ctrl+shift+semicolon...
Once again, adding keybind = ctrl+shift+semicolon=reload_config makes the reloading work as expected from the default ctrl+shift+plus keybind.
Bottom line
Not sure if this goes slightly off topic, as it also exposes issues with the shift key for the keybinds on my swiss layout. I do not recall this kind of thing being an issue on other terminals (or in neovim). The only issue I might have encountered here and there, would be that I needed to make ctrl+shift+comma to be ctrl+semicolon since shift+comma gives me a ; on the swiss layout.
However, the c-] not working in neovim is quite a problem. I do not use it often, but it is quite essential for navigating vim's help pages. For now, I added another mapping for this to circumvent the immediate problem, but hopefully there is a more general fix to address these in a more keyboard layout agnostic manner.
Swiss french layout for reference:
I am having a similar problem with this. When I press "~" on ghostty terminal, it waits for me to type a letter to place the tilde, like "ã". But when I type any letter, it just cleans the display. I've noticed it when I was trying to go to my home directory like cd ~/. I pressed ~ and / but it just made a funny sound and kept waiting. I also can't use any other accentuation character of the Portuguese language in the ghostty terminal. So I can't write words like "amanhã", "vÃdeo" etc. It would be awesome to add support for latin languages. But this doesn't bother me as much as the ~/ thing, cause I use this shortcut a lot on other terminals. Note: My keyboard has the Brazilian Portuguese layout (ABNT2)
Same here. I'm not able to type ~ (tilde), ` (backtick) and ^ (circumflex) on my de_CH keyboard. When I type one of those characters, Ghostty (1.1.0-arch) displays it, but pressing space to continue with this character doen't work. The character disappears again.
In my opinion this (tilde, backtick, circumflex) was fixed with
1.1.1-arch.
For me on Swedish keyboard no characters modifiers (eg. ^, ~, ", ', ` ) are not working on 1.2.0-arch1. So, clearly it has not been fixed. ±, which is on the same key and with AlgGr does work. For further context I am on Wayland in Arch linux.
In my opinion this (tilde, backtick, circumflex) was fixed with
1.1.1-arch.For me on Swedish keyboard no characters modifiers (eg. ^, ~, ", ', ` ) are not working on 1.2.0-arch1. So, clearly it has not been fixed. ±, which is on the same key and with AlgGr does work. For further context I am on Wayland in Arch linux.
Having the same problem on a Norwegian keyboard on Wayland and Arch Linux. Pressing AltGr in combination with ¨ to produce a ~ I get nothing in Ghostty.
it seems i am having a similar problem with Brazilian Portuguese keyboard layout (br-abnt2) but in my case it looks like the layout its not being detected correctly it looks like it is using the us layout instead.
here i am typing the tilde key on my keyboard and the quote key is what appears on the inspector
however if i press the AltGr key the tilde key is typed
I'm not sure about the original issue, but regarding the recent comments, have you tried the fix mentioned here: #8899? I had similar issues with Finnish keyboard and this resolved the issue for me.
Thank you that was it, also i am sorry for cluttering this issue if i had looked better before commenting here i am sure i would have found it.