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

Key presses happen twice on Windows #514

Open
sunrosa opened this issue Jan 30, 2024 · 4 comments
Open

Key presses happen twice on Windows #514

sunrosa opened this issue Jan 30, 2024 · 4 comments
Labels
S-bug Severity: bug

Comments

@sunrosa
Copy link

sunrosa commented Jan 30, 2024

What crate(s) in this repo are involved in the problem?

tokio-console

What is the issue?

Whenever pressing a key in the tokio-console ui, it presses twice. Pressing j goes down two elements. Pressing space pauses then unpauses. Both keys press instantly. It doesn't matter when I release the key.

How can the bug be reproduced?

Run tokio-console on Windows 10 (or Windows 11, apparently) on Powershell or Git Bash. The bug happened on the Tabby terminal emulator and on the VSCode terminal emulator.

Logs, error output, etc

No response

Versions

console-subscriber v0.2.0
console-api v0.6.0

tokio-console 0.1.10

Possible solution

I remember seeing somewhere that Windows key events fire on both key pressed and key released, while Unix key events only fire on key pressed. It may be the other way around.

Additional context

No response

Would you like to work on fixing this bug?

maybe

@sunrosa sunrosa added the S-bug Severity: bug label Jan 30, 2024
@hawkw
Copy link
Member

hawkw commented Feb 10, 2024

Interesting, thanks for the report! I wonder if there's something we can enable in crossterm/ratatui to make its key event behavior on Windows consistent with other platforms?

If not, we could certainly implement some windows-specific logic to work around this in the console. But, it seems like there ought to be something in the terminal UI libraries for it...

@damccull
Copy link

I'm also having this issue.
Windows 11
New terminal app
nushell

@damccull
Copy link

For me, #515 fixes this problem.

@joshka
Copy link
Contributor

joshka commented Feb 17, 2024

Interesting, thanks for the report! I wonder if there's something we can enable in crossterm/ratatui to make its key event behavior on Windows consistent with other platforms?

Ratatui doesn't have anything that handles the actual key events, the code for this is all in Crossterm.
In Crossterm, there's an open issue to put the KeyPress events behind a feature flag, as it caught a number of people off guard (and makes upgrading apps from 0.26 to 0.27 kinda annoying). Until then it's pretty easy to check for event.kind == KeyEventKind::Press instead.

@sunrosa sunrosa changed the title Keys presses twice on Windows Key presses happen twice on Windows Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-bug Severity: bug
Projects
None yet
Development

No branches or pull requests

4 participants