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

Double key input on Windows #772

Closed
jasiukiewicztymon opened this issue Apr 1, 2023 · 9 comments · Fixed by #775
Closed

Double key input on Windows #772

jasiukiewicztymon opened this issue Apr 1, 2023 · 9 comments · Fixed by #775

Comments

@jasiukiewicztymon
Copy link

Describe the bug
When I use the event::read function I have double input, and it does like I have clicked a key two times. When I tried it on my WSL it worked..

To Reproduce
Steps to reproduce the behavior:

  1. Use the Rust tui lib tab example
  2. Run the code on windows
  3. See error

Expected behavior
Fix this

OS

  • Windows

Terminal/Console

  • CMD
  • PowerShell
  • Windows Terminal
@TimonPost
Copy link
Member

Its like key press/release

@jasiukiewicztymon
Copy link
Author

Ok.. but why it doesn't occur on every terminal but only on Window's one?

@TimonPost
Copy link
Member

good question, and actually, I think this needs to be reverted. On UNIX systems its supported under the kitty protocol. But as its not supported all over it should likely be disabled by default and enabled behind feature flag

@jasiukiewicztymon
Copy link
Author

ok, waiting to be fixed so... But it would be a big change no?

@TimonPost
Copy link
Member

TimonPost commented Apr 2, 2023

not really. In the meantime just match on the https://docs.rs/crossterm/latest/crossterm/event/struct.KeyEvent.html kind field. So you can easily always make sure you are expecting key-press only.

@lesleyrs
Copy link
Contributor

lesleyrs commented Apr 2, 2023

I was just trying out event-poll-read as well using both wezterm and windows terminal on windows, wezterm doesn't actually have the double input problem. But it still has the enter release event at the start.

However I noticed that on WSL, there aren't any release events on either terminal. Am I not understanding something here?

Edit: Also what is even causing the difference in wezterm and windows terminal? Disabling kitty didn't change this, disabling win32 made it even worse than windows terminal where even arrow keys don't work properly.

@lesleyrs
Copy link
Contributor

lesleyrs commented Apr 6, 2023

Hey I spend some time figuring this out and I explained it in my PR.

But to sum it up:

cmd on conhost works as intended, then any other combination of cmd, powershell, conhost and wezterm (maybe others) works but you get the unintended "release" event at the start.

The only one which doesn't work well is windows terminal regardless of shell which means you can't use it for detecting held keys if they produce a letter. They might get it fixed eventually as well, it's being tracked here #775 (comment). But it still works fine as long as you check for either press or release.

@lesleyrs
Copy link
Contributor

lesleyrs commented Apr 7, 2023

@TimonPost this one is already open for the same issue #752

@TimonPost
Copy link
Member

Closing as duplicate then

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 a pull request may close this issue.

3 participants