Skip to content

Commit

Permalink
fix #390
Browse files Browse the repository at this point in the history
  • Loading branch information
deepu105 committed Jan 8, 2024
1 parent 9d3cdfc commit 9aac7eb
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/event/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -93,3 +91,15 @@ impl Events {
self.rx.recv()
}
}

#[cfg(target_os = "windows")]
fn handle_key_event(event_tx: &mpsc::Sender<Event<KeyEvent, MouseEvent>>, 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<Event<KeyEvent, MouseEvent>>, key_event: KeyEvent) {
event_tx.send(Event::Input(key_event)).unwrap();
}

0 comments on commit 9aac7eb

Please sign in to comment.