Skip to content

Commit aa4266c

Browse files
pm100extrawurst
authored andcommitted
fix double key input on windows due to crossterm 0.26
1 parent d6f3353 commit aa4266c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/input.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::notify_mutex::NotifyableMutex;
22
use anyhow::Result;
33
use crossbeam_channel::{unbounded, Receiver, Sender};
4-
use crossterm::event::{self, Event};
4+
use crossterm::event::{self, Event, Event::Key, KeyEventKind};
55
use std::{
66
sync::{
77
atomic::{AtomicBool, Ordering},
@@ -113,6 +113,12 @@ impl Input {
113113
arc_current.store(true, Ordering::Relaxed);
114114

115115
if let Some(e) = Self::poll(POLL_DURATION)? {
116+
// windows send key release too, only process key press
117+
if let Key(key) = e {
118+
if key.kind != KeyEventKind::Press {
119+
continue;
120+
}
121+
}
116122
tx.send(InputEvent::Input(e))?;
117123
}
118124
} else {

0 commit comments

Comments
 (0)