Fix duplicated key presses on windows
This commit is contained in:
parent
88ba77b955
commit
e0948c4f1c
2 changed files with 9 additions and 4 deletions
|
|
@ -33,6 +33,7 @@ Procedure when bumping the version number:
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Room deletion popup accepting any room name
|
- Room deletion popup accepting any room name
|
||||||
|
- Duplicated key presses on Windows
|
||||||
|
|
||||||
## v0.7.1 - 2023-08-31
|
## v0.7.1 - 2023-08-31
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use std::io;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
pub use cove_macro::KeyGroup;
|
pub use cove_macro::KeyGroup;
|
||||||
use crossterm::event::{Event, KeyEvent};
|
use crossterm::event::{Event, KeyEvent, KeyEventKind};
|
||||||
use parking_lot::FairMutex;
|
use parking_lot::FairMutex;
|
||||||
use toss::{Frame, Terminal, WidthDb};
|
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<KeyEvent> {
|
pub fn key_event(&self) -> Option<KeyEvent> {
|
||||||
match &self.event {
|
if let Event::Key(event) = &self.event {
|
||||||
Event::Key(event) => Some(*event),
|
if matches!(event.kind, KeyEventKind::Press | KeyEventKind::Repeat) {
|
||||||
_ => None,
|
return Some(*event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn paste_event(&self) -> Option<&str> {
|
pub fn paste_event(&self) -> Option<&str> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue