fix: filter KeyEventKind::Press out (#137)
to ignore all the other `CrosstermEvent::Key` events
This commit is contained in:
parent
513f1fec11
commit
27cb8c7e33
@ -1,4 +1,4 @@
|
|||||||
use crossterm::event::{Event as CrosstermEvent, EventStream};
|
use crossterm::event::{Event as CrosstermEvent, EventStream, KeyEventKind};
|
||||||
use futures::{Stream, StreamExt};
|
use futures::{Stream, StreamExt};
|
||||||
use ratatui::layout::Position;
|
use ratatui::layout::Position;
|
||||||
use std::{pin::Pin, time::Duration};
|
use std::{pin::Pin, time::Duration};
|
||||||
@ -92,7 +92,10 @@ fn crossterm_stream() -> Pin<Box<dyn Stream<Item = TuiEvent>>> {
|
|||||||
// we are not interested in all events
|
// we are not interested in all events
|
||||||
.filter_map(|result| async move {
|
.filter_map(|result| async move {
|
||||||
match result {
|
match result {
|
||||||
Ok(event) => Some(TuiEvent::Crossterm(event)),
|
// filter `KeyEventKind::Press` out to ignore all the other `CrosstermEvent::Key` events
|
||||||
|
Ok(CrosstermEvent::Key(key)) => (key.kind == KeyEventKind::Press)
|
||||||
|
.then_some(TuiEvent::Crossterm(CrosstermEvent::Key(key))),
|
||||||
|
Ok(other) => Some(TuiEvent::Crossterm(other)),
|
||||||
Err(_) => Some(TuiEvent::Error),
|
Err(_) => Some(TuiEvent::Error),
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user