diff --git a/CHANGELOG.md b/CHANGELOG.md index ffc13d6e..514ab220 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Downgrade crossterm and update time crates (#659) +- Monitor now only sends key presses on key down events ### Changed diff --git a/espflash/src/cli/monitor/mod.rs b/espflash/src/cli/monitor/mod.rs index 08f55bf4..1d733639 100644 --- a/espflash/src/cli/monitor/mod.rs +++ b/espflash/src/cli/monitor/mod.rs @@ -15,6 +15,7 @@ use std::{ time::Duration, }; +use crossterm::event::KeyEventKind; use crossterm::{ event::{poll, read, Event, KeyCode, KeyEvent, KeyModifiers}, terminal::{disable_raw_mode, enable_raw_mode}, @@ -116,20 +117,22 @@ pub fn monitor( if interactive_mode && poll(Duration::from_secs(0)).into_diagnostic()? { if let Event::Key(key) = read().into_diagnostic()? { - if key.modifiers.contains(KeyModifiers::CONTROL) { - match key.code { - KeyCode::Char('c') => break, - KeyCode::Char('r') => { - reset_after_flash(&mut serial, pid).into_diagnostic()?; - continue; + if key.kind == KeyEventKind::Press { + if key.modifiers.contains(KeyModifiers::CONTROL) { + match key.code { + KeyCode::Char('c') => break, + KeyCode::Char('r') => { + reset_after_flash(&mut serial, pid).into_diagnostic()?; + continue; + } + _ => {} } - _ => {} } - } - if let Some(bytes) = handle_key_event(key) { - serial.write_all(&bytes).into_diagnostic()?; - serial.flush().into_diagnostic()?; + if let Some(bytes) = handle_key_event(key) { + serial.write_all(&bytes).into_diagnostic()?; + serial.flush().into_diagnostic()?; + } } } }