Module keys

Module keys 

Source
Expand description

Key bindings and keyboard input handling for list navigation.

This module defines the key mapping system that controls how users interact with the list component. It includes:

  • ListKeyMap: Configurable key bindings for all list operations
  • Default key mappings following common terminal UI conventions
  • Support for custom key binding overrides

The key system integrates with the help system to provide contextual keyboard shortcuts based on the current list state.

§Examples

use bubbletea_widgets::list::{Model, DefaultDelegate, DefaultItem, ListKeyMap};

let items = vec![DefaultItem::new("Item", "Description")];
let list = Model::new(items, DefaultDelegate::new(), 80, 24);

// The key mappings are used internally by the list component
// They can be customized when creating custom list implementations

Key bindings for list component navigation and interaction.

This module defines the ListKeyMap which contains all the key bindings used by the list component for navigation, filtering, and interaction. The key bindings follow common terminal UI conventions and vim-style navigation patterns.

  • Cursor Movement: ↑/k (up), ↓/j (down)
  • Page Navigation: →/l/pgdn/f/d (next page), ←/h/pgup/b/u (prev page)
  • Jump Navigation: g/home (go to start), G/end (go to end)

§Filtering Keys

  • Start Filter: / (enter filtering mode)
  • Clear Filter: esc (clear active filter)
  • Cancel Filter: esc (cancel filter input)
  • Accept Filter: enter/tab/↑/↓ (apply filter and continue)

§Help and Quit Keys

  • Help: ? (show/hide help)
  • Quit: q/esc (normal quit)
  • Force Quit: ctrl+c (immediate quit)

§Example

use bubbletea_widgets::list::ListKeyMap;
use bubbletea_widgets::key::KeyMap;

let keymap = ListKeyMap::default();
let help = keymap.short_help(); // Get key bindings for help display

Structs§

ListKeyMap
Key bindings for list navigation, filtering, help, and exit actions.