console icon indicating copy to clipboard operation
console copied to clipboard

Key presses happen twice on Windows

Open sunrosa opened this issue 1 year ago • 4 comments

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 avatar Jan 30 '24 22:01 sunrosa

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

hawkw avatar Feb 10 '24 17:02 hawkw

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

damccull avatar Feb 14 '24 15:02 damccull

For me, #515 fixes this problem.

damccull avatar Feb 15 '24 08:02 damccull

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.

joshka avatar Feb 17 '24 05:02 joshka