diff --git a/examples/canvas.rs b/examples/canvas.rs index 142f7c57..04d2ffb4 100644 --- a/examples/canvas.rs +++ b/examples/canvas.rs @@ -59,10 +59,10 @@ impl App { if let Event::Key(key) = event::read()? { match key.code { KeyCode::Char('q') => break, - KeyCode::Down => app.y += 1.0, - KeyCode::Up => app.y -= 1.0, - KeyCode::Right => app.x += 1.0, - KeyCode::Left => app.x -= 1.0, + KeyCode::Down | KeyCode::Char('j') => app.y += 1.0, + KeyCode::Up | KeyCode::Char('k') => app.y -= 1.0, + KeyCode::Right | KeyCode::Char('l') => app.x += 1.0, + KeyCode::Left | KeyCode::Char('h') => app.x -= 1.0, _ => {} } } diff --git a/examples/custom_widget.rs b/examples/custom_widget.rs index f338d147..97507692 100644 --- a/examples/custom_widget.rs +++ b/examples/custom_widget.rs @@ -216,12 +216,12 @@ fn handle_key_event( ) -> ControlFlow<()> { match key.code { KeyCode::Char('q') => return ControlFlow::Break(()), - KeyCode::Left => { + KeyCode::Left | KeyCode::Char('h') => { button_states[*selected_button] = State::Normal; *selected_button = selected_button.saturating_sub(1); button_states[*selected_button] = State::Selected; } - KeyCode::Right => { + KeyCode::Right | KeyCode::Char('l') => { button_states[*selected_button] = State::Normal; *selected_button = selected_button.saturating_add(1).min(2); button_states[*selected_button] = State::Selected; diff --git a/examples/demo/crossterm.rs b/examples/demo/crossterm.rs index 35e5e1fb..907c3645 100644 --- a/examples/demo/crossterm.rs +++ b/examples/demo/crossterm.rs @@ -55,11 +55,11 @@ fn run_app( if let Event::Key(key) = event::read()? { if key.kind == KeyEventKind::Press { match key.code { + KeyCode::Left | KeyCode::Char('h') => app.on_left(), + KeyCode::Up | KeyCode::Char('k') => app.on_up(), + KeyCode::Right | KeyCode::Char('l') => app.on_right(), + KeyCode::Down | KeyCode::Char('j') => app.on_down(), KeyCode::Char(c) => app.on_key(c), - KeyCode::Left => app.on_left(), - KeyCode::Up => app.on_up(), - KeyCode::Right => app.on_right(), - KeyCode::Down => app.on_down(), _ => {} } } diff --git a/examples/demo/termion.rs b/examples/demo/termion.rs index d2b9a7cf..47d828f6 100644 --- a/examples/demo/termion.rs +++ b/examples/demo/termion.rs @@ -39,11 +39,11 @@ fn run_app( match events.recv()? { Event::Input(key) => match key { + Key::Up | Key::Char('k') => app.on_up(), + Key::Down | Key::Char('j') => app.on_down(), + Key::Left | Key::Char('h') => app.on_left(), + Key::Right | Key::Char('l') => app.on_right(), Key::Char(c) => app.on_key(c), - Key::Up => app.on_up(), - Key::Down => app.on_down(), - Key::Left => app.on_left(), - Key::Right => app.on_right(), _ => {} }, Event::Tick => app.on_tick(), diff --git a/examples/demo/termwiz.rs b/examples/demo/termwiz.rs index 2b0350e5..e90c85c2 100644 --- a/examples/demo/termwiz.rs +++ b/examples/demo/termwiz.rs @@ -45,10 +45,10 @@ fn run_app( { match input { InputEvent::Key(key_code) => match key_code.key { - KeyCode::UpArrow => app.on_up(), - KeyCode::DownArrow => app.on_down(), - KeyCode::LeftArrow => app.on_left(), - KeyCode::RightArrow => app.on_right(), + KeyCode::UpArrow | KeyCode::Char('k') => app.on_up(), + KeyCode::DownArrow | KeyCode::Char('j') => app.on_down(), + KeyCode::LeftArrow | KeyCode::Char('h') => app.on_left(), + KeyCode::RightArrow | KeyCode::Char('l') => app.on_right(), KeyCode::Char(c) => app.on_key(c), _ => {} }, diff --git a/examples/list.rs b/examples/list.rs index 885d8e76..9f043874 100644 --- a/examples/list.rs +++ b/examples/list.rs @@ -181,9 +181,9 @@ fn run_app( if key.kind == KeyEventKind::Press { match key.code { KeyCode::Char('q') => return Ok(()), - KeyCode::Left => app.items.unselect(), - KeyCode::Down => app.items.next(), - KeyCode::Up => app.items.previous(), + KeyCode::Left | KeyCode::Char('h') => app.items.unselect(), + KeyCode::Down | KeyCode::Char('j') => app.items.next(), + KeyCode::Up | KeyCode::Char('k') => app.items.previous(), _ => {} } } diff --git a/examples/table.rs b/examples/table.rs index b639a8f6..5eecf9da 100644 --- a/examples/table.rs +++ b/examples/table.rs @@ -104,8 +104,8 @@ fn run_app(terminal: &mut Terminal, mut app: App) -> io::Result<( if key.kind == KeyEventKind::Press { match key.code { KeyCode::Char('q') => return Ok(()), - KeyCode::Down => app.next(), - KeyCode::Up => app.previous(), + KeyCode::Down | KeyCode::Char('j') => app.next(), + KeyCode::Up | KeyCode::Char('k') => app.previous(), _ => {} } } diff --git a/examples/tabs.rs b/examples/tabs.rs index ecb19a4f..8ed77584 100644 --- a/examples/tabs.rs +++ b/examples/tabs.rs @@ -69,8 +69,8 @@ fn run_app(terminal: &mut Terminal, mut app: App) -> io::Result<( if key.kind == KeyEventKind::Press { match key.code { KeyCode::Char('q') => return Ok(()), - KeyCode::Right => app.next(), - KeyCode::Left => app.previous(), + KeyCode::Right | KeyCode::Char('l') => app.next(), + KeyCode::Left | KeyCode::Char('h') => app.previous(), _ => {} } }