Skip to main content

Module key

Module key 

Source
Expand description

Keybinding definitions and matching utilities.

This module provides types for defining keybindings and matching them against key events. It’s useful for creating user-configurable keymaps in TUI applications.

§Example

use bubbles::key::{Binding, matches};

let up = Binding::new()
    .keys(&["k", "up"])
    .help("↑/k", "move up");

let down = Binding::new()
    .keys(&["j", "down"])
    .help("↓/j", "move down");

// Check if a key matches
assert!(matches("k", &[&up, &down]));
assert!(matches("down", &[&up, &down]));
assert!(!matches("x", &[&up, &down]));

Structs§

Binding
A keybinding with associated help text.
Help
Help information for a keybinding.

Functions§

matches
Checks if the given key matches any of the given bindings.
matches_one
Checks if the given key matches a single binding.