-
Notifications
You must be signed in to change notification settings - Fork 313
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
Duplicate Key Events on Windows #347
Comments
Hi there. This has come up a few times. See https://docs.rs/crossterm/latest/crossterm/event/struct.KeyEvent.html That's a probably a difficult one as ratatui doesn't have any code to handle keyboard input (other than our examples). Can you help us out (and perhaps the next person who hits this) by noting where in the docs you looked for this and didn't find enough info? |
Honestly the only docs I read were the readme.md and the examples, and also the relevant data structures and methods that I used. But the examples are wrong on windows though! |
Could you elaborate on why they are wrong ? |
Well the expected behaviour would be that the down key only moves down by one but it moves down by two! |
Ah, I'm very dumb. I took the example from tui-rs not ratatui. I'm sorry about that! |
So that fixes your issue ? |
Yes. tui-rs should be officially deprecated at this point... |
Crossterm 0.26+ reports key release events on windows, which results in the application seeing multiple events for a single key press. See ratatui/ratatui#347 for more info. Fixes YS-L#30
* Migrate to Ratatui Ratatui is a replacement for tui-rs that is actively maintained. See https://ratatui.rs/ for more info. * fix: only respond to key press events Crossterm 0.26+ reports key release events on windows, which results in the application seeing multiple events for a single key press. See ratatui/ratatui#347 for more info. Fixes #30
Issue summary
On Windows, Crossterm will report both KeyPress and KeyRelease events. To avoid registering an event twice, ensure that you check the
kind
field of theKeyEvent
. See also:Description
When I type any keyboard input the event fires twice: Once on press and once on release.
2023-07-26.06-29-42.mp4
To Reproduce
https://github.com/fdehau/tui-rs/blob/master/examples/user_input.rs
Environment
Additional context
It works for some reason in another project where it was failing until I refactored the display logic to another function
The text was updated successfully, but these errors were encountered: