aboutsummaryrefslogtreecommitdiff
path: root/src/event.rs
blob: bfe1fa5db245b01b9eae458168a97d7114913249 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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)
}