Skip to content

Commit 36bea52

Browse files
authored
Monitor input only sends key on press now, not on release (#661)
1 parent 2334907 commit 36bea52

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
### Fixed
1515
- Downgrade crossterm and update time crates (#659)
16+
- Monitor now only sends key presses on key down events
1617

1718
### Changed
1819

espflash/src/cli/monitor/mod.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use std::{
1515
time::Duration,
1616
};
1717

18+
use crossterm::event::KeyEventKind;
1819
use crossterm::{
1920
event::{poll, read, Event, KeyCode, KeyEvent, KeyModifiers},
2021
terminal::{disable_raw_mode, enable_raw_mode},
@@ -116,20 +117,22 @@ pub fn monitor(
116117

117118
if interactive_mode && poll(Duration::from_secs(0)).into_diagnostic()? {
118119
if let Event::Key(key) = read().into_diagnostic()? {
119-
if key.modifiers.contains(KeyModifiers::CONTROL) {
120-
match key.code {
121-
KeyCode::Char('c') => break,
122-
KeyCode::Char('r') => {
123-
reset_after_flash(&mut serial, pid).into_diagnostic()?;
124-
continue;
120+
if key.kind == KeyEventKind::Press {
121+
if key.modifiers.contains(KeyModifiers::CONTROL) {
122+
match key.code {
123+
KeyCode::Char('c') => break,
124+
KeyCode::Char('r') => {
125+
reset_after_flash(&mut serial, pid).into_diagnostic()?;
126+
continue;
127+
}
128+
_ => {}
125129
}
126-
_ => {}
127130
}
128-
}
129131

130-
if let Some(bytes) = handle_key_event(key) {
131-
serial.write_all(&bytes).into_diagnostic()?;
132-
serial.flush().into_diagnostic()?;
132+
if let Some(bytes) = handle_key_event(key) {
133+
serial.write_all(&bytes).into_diagnostic()?;
134+
serial.flush().into_diagnostic()?;
135+
}
133136
}
134137
}
135138
}

0 commit comments

Comments
 (0)