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

AltGr keys produce alt and ctrl modifier on windows #820

Open
pascalkuthe opened this issue Sep 13, 2023 · 3 comments
Open

AltGr keys produce alt and ctrl modifier on windows #820

pascalkuthe opened this issue Sep 13, 2023 · 3 comments

Comments

@pascalkuthe
Copy link

pascalkuthe commented Sep 13, 2023

Describe the bug
This issue was first reported in helix-editor/helix#7129 including a reprocutions case. I did some digging there (helix-editor/helix#7129 (comment)) AltGr handling seems a mess on windows but I do think this may be a bug in crossterm.
Disclaimer that i don't have a windows machine or a keyboard that uses altgr at hand myself so I didn't test this myself but the original reproduction case was confirmed by multiple people in helix and we don't do any processing of crossterm key events.

I cameup with the reproduction case below but I can't test it myself:

To Reproduce
Steps to reproduce the behavior:

  1. Open windows terminal
  2. run the event-read exmaple
  3. use a german keyboard layout and press altgr-7 to type {
  4. Observe modifier Alt | Ctrl in the key event (with char {)

Expected behavior
A key event for { without modifier is emitted.

OS
Windows

Terminal/Console
Windows Terminal (stable and preview) and Git Bash (+winpty)

@sigmaSd
Copy link
Contributor

sigmaSd commented Sep 13, 2023

As far as I know that's how windows sends them https://github.com/microsoft/Terminal/blob/660d31ac522186e615ec243de2a434c273464828/src/terminal/input/terminalInput.cpp#L400-L419

I think it's a good idea to check what termwiz do here.

@pascalkuthe
Copy link
Author

yeah I am aware, see my liked comment in the helix issue. But that is not really how applications are supposed to interpret it AFAIK (its some legacy stuff as always on windows).

The snippet you liked does exactly what i was suggesting: Removing the lctr and ralt modifiers in case they are pressed simultaneously. I am not really aware of windows terminal internals and why they are stripping it there but still sending it trough to the tui (perphaps that code is just for internal keymap handling).

Termwiz doesn't seem to handle this altough I am not sure. There seems to be some handling for it but at the wezterm layer rather than inside termwiz

@pascalkuthe
Copy link
Author

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

No branches or pull requests

2 participants