console-rs / console-rs/console
Key bypasses read_key() when more than one key pressed together
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.2k
- Forks
- 144
- Avg merge
- 8h 24m
- Merged PRs (30d)
- 4
Description
First of all thanks for creating this crate :)
I am having an issue that when I am using read_key() and press more than one character key at the same time, sometimes one of them bypasses the method and is written to the terminal.
For example with the following code:
loop {
let term = Term::stdout();
if let Key::Char(thing) = term.read_key().unwrap() {
term.write_line(&format!("{}", style(" thing").green().bold()))?;
}
}
if I press j and k at the same time the output is something like:
thing
thing
thing
k thing
thing
k thing
thing
j thing
Not sure if I am using it wrong or if there is an issue here.
Thanks!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Begin with the read_key() call in the provided loop and reproduce the issue by pressing multiple character keys together. Trace how those key events are read and written to the terminal; done means every pressed key is handled by read_key() without appearing as raw terminal output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100