From 9aac7eb118002f4a25d6b034fc5fad5ed43b1f05 Mon Sep 17 00:00:00 2001 From: Deepu Date: Mon, 8 Jan 2024 18:21:48 +0100 Subject: [PATCH] fix https://github.com/kdash-rs/kdash/issues/390 --- src/event/events.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/event/events.rs b/src/event/events.rs index 415674eb..a9fa956f 100644 --- a/src/event/events.rs +++ b/src/event/events.rs @@ -68,9 +68,7 @@ impl Events { // poll for tick rate duration, if no event, sent tick event. if event::poll(timeout).unwrap() { match event::read().unwrap() { - CEvent::Key(key_event) => { - event_tx.send(Event::Input(key_event)).unwrap(); - } + CEvent::Key(key_event) => handle_key_event(&event_tx, key_event), CEvent::Mouse(mouse_event) => { event_tx.send(Event::MouseInput(mouse_event)).unwrap(); } @@ -93,3 +91,15 @@ impl Events { self.rx.recv() } } + +#[cfg(target_os = "windows")] +fn handle_key_event(event_tx: &mpsc::Sender>, key_event: KeyEvent) { + if key_event.kind == event::KeyEventKind::Press { + event_tx.send(Event::Input(key_event)).unwrap(); + } +} + +#[cfg(not(target_os = "windows"))] +fn handle_key_event(event_tx: &mpsc::Sender>, key_event: KeyEvent) { + event_tx.send(Event::Input(key_event)).unwrap(); +}