diff --git a/CHANGELOG.md b/CHANGELOG.md index cfc6a53..c4c3968 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ Procedure when bumping the version number: ### Fixed - Room deletion popup accepting any room name +- Duplicated key presses on Windows ## v0.7.1 - 2023-08-31 diff --git a/cove-input/src/lib.rs b/cove-input/src/lib.rs index b42fdcb..ba3bd63 100644 --- a/cove-input/src/lib.rs +++ b/cove-input/src/lib.rs @@ -4,7 +4,7 @@ use std::io; use std::sync::Arc; pub use cove_macro::KeyGroup; -use crossterm::event::{Event, KeyEvent}; +use crossterm::event::{Event, KeyEvent, KeyEventKind}; use parking_lot::FairMutex; use toss::{Frame, Terminal, WidthDb}; @@ -58,11 +58,15 @@ impl<'a> InputEvent<'a> { } } + /// If the current event represents a key press, returns the [`KeyEvent`] + /// associated with that key press. pub fn key_event(&self) -> Option { - match &self.event { - Event::Key(event) => Some(*event), - _ => None, + if let Event::Key(event) = &self.event { + if matches!(event.kind, KeyEventKind::Press | KeyEventKind::Repeat) { + return Some(*event); + } } + None } pub fn paste_event(&self) -> Option<&str> {