diff options
Diffstat (limited to 'src/event.rs')
| -rw-r--r-- | src/event.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/event.rs b/src/event.rs new file mode 100644 index 0000000..bfe1fa5 --- /dev/null +++ b/src/event.rs @@ -0,0 +1,18 @@ +use std::io; + +use ratatui::crossterm::event::{self, Event, KeyCode}; + +use crate::app::App; + +pub fn handle_event(app: &mut App) -> io::Result<bool> { + if let Event::Key(key) = event::read()? { + match key.code { + KeyCode::Char('q') => return Ok(true), + KeyCode::Char('j') => app.list_state.select_next(), + KeyCode::Char('k') => app.list_state.select_previous(), + _ => return Ok(false), + } + } + + Ok(false) +} |
