Skip to content

Commit

Permalink
Merge pull request #2677 from jasagredo/js/get-single-char-windows
Browse files Browse the repository at this point in the history
Ignore `KeyEventKind::Release` events when reading a char
  • Loading branch information
mthom authored Dec 6, 2024
2 parents 0427d9e + 8e5ddeb commit ea02b54
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/machine/system_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ use cpu_time::ProcessTime;
use std::time::{Duration, SystemTime};

#[cfg(feature = "repl")]
use crossterm::event::{read, Event, KeyCode, KeyEvent, KeyModifiers};
use crossterm::event::{read, Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers};
#[cfg(feature = "repl")]
use crossterm::terminal::{disable_raw_mode, enable_raw_mode};

Expand Down Expand Up @@ -111,12 +111,14 @@ pub(crate) fn get_key() -> KeyEvent {
loop {
let key_ = read();
if let Ok(Event::Key(key_)) = key_ {
match key_.code {
KeyCode::Char(_) | KeyCode::Enter | KeyCode::Tab => {
key = key_;
break;
if key_.kind != KeyEventKind::Release {
match key_.code {
KeyCode::Char(_) | KeyCode::Enter | KeyCode::Tab => {
key = key_;
break;
}
_ => (),
}
_ => (),
}
}
}
Expand Down

0 comments on commit ea02b54

Please sign in to comment.