use crossterm::event::{Event, KeyCode}; use crate::app::App; pub fn handle_input(app: &mut App, event: Event) -> bool { if app.show_welcome { if let Event::Key(_) = event { app.show_welcome = false; } } else if app.show_help { if let Event::Key(key) = event { match key.code { KeyCode::Char('q') | KeyCode::Esc | KeyCode::Char('?') | KeyCode::Enter | KeyCode::Backspace => app.show_help = false, _ => {} } } } else { if let Event::Key(key) = event { match key.code { KeyCode::Char('h') | KeyCode::Left => app.move_left(), KeyCode::Char('l') | KeyCode::Right => app.move_right(), KeyCode::Char('j') | KeyCode::Down => app.move_down(), KeyCode::Char('k') | KeyCode::Up => app.move_up(), KeyCode::Char('?') => app.show_help = true, KeyCode::Char('q') | KeyCode::Esc => return false, _ => {} } } } true }