console-rs / console-rs/console

Key bypasses read_key() when more than one key pressed together

Open
#152 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.