Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kitty keyboard protocol: AltGr+plus should produce a tilde, but produces a plus instead #2981

Open
neurocyte opened this issue Dec 16, 2024 · 20 comments
Labels
input Keyboard or mouse input os/linux

Comments

@neurocyte
Copy link
Collaborator

neurocyte commented Dec 16, 2024

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
@neurocyte
Copy link
Collaborator Author

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

@mitchellh
Copy link
Contributor

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?

@mitchellh mitchellh added os/linux input Keyboard or mouse input needs-confirmation A reproduction has been reported, but the bug hasn't been confirmed or reproduced by a maintainer. labels Dec 16, 2024
@mitchellh
Copy link
Contributor

Also, can you share perhaps a picture of the keyboard layout and exactly which key you're pressing?

@neurocyte
Copy link
Collaborator Author

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 ~.

@neurocyte
Copy link
Collaborator Author

neurocyte commented Dec 16, 2024

Image

This shows all the AltGr modifyable keys on a german keyboard. They are the lower right symbols.

@mitchellh
Copy link
Contributor

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

@neurocyte
Copy link
Collaborator Author

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?

Image

@mitchellh
Copy link
Contributor

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?

@mitchellh
Copy link
Contributor

mitchellh commented Dec 16, 2024

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.

@gpanders
Copy link
Member

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.

@rockorager
Copy link
Collaborator

rockorager commented Dec 16, 2024

+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.

@mitchellh
Copy link
Contributor

Thanks. I've posted the problem, without a solution, here: kovidgoyal/kitty#8126

@mitchellh
Copy link
Contributor

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.

@neurocyte
Copy link
Collaborator Author

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.

@mitchellh mitchellh removed the needs-confirmation A reproduction has been reported, but the bug hasn't been confirmed or reproduced by a maintainer. label Dec 20, 2024
@gpanders
Copy link
Member

A similar issue (QWERTZ layout on a German keyboard) reported here neovim/neovim#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.

@keuwey
Copy link

keuwey commented Feb 2, 2025

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)

@echo-gravitas
Copy link

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.

@KRVPerera
Copy link

KRVPerera commented Feb 5, 2025

I am now having trouble typing ^ character in Finnish keyboard. But this happens only when using tmux inside ghostty (ghostty 1.1.0)

Image

@echo-gravitas
Copy link

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.

@keuwey
Copy link

keuwey commented Feb 14, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
input Keyboard or mouse input os/linux
Projects
None yet
Development

No branches or pull requests

7 participants