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

Fix event-read-char-line example double read error & auto enter #954

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hthuz
Copy link

@hthuz hthuz commented Dec 11, 2024

I tried following the example in event-read-char-line to read keyboard character event without having to press enter. I met some problems when I tried this example.

The first problem is double key input in Windows. I tracked issue #772 and it turns out kind: KeyEventKind::Press is not added when reading event in this example.

The second problem is with read_line() function. It seems that it captures the pressed Enter command when I run cargo run --example event-read-char-line.

The third problem is, I have to press Enter for read_char() to get my keyboard input in WSL.

I played with this example for some time and compared with other examples. I made some modifications and they should fix these problems. For read_line(), I don't know exactly why the original while doesn't work but replacing it with loop does solve the second problem.

@hthuz
Copy link
Author

hthuz commented Dec 13, 2024

Hi @TimonPost could you review it when you have a chance? I'd appreciate your comments and feedbacks. Thank you!

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 this pull request may close these issues.

1 participant