Expand description
Cleanroom Rust port of upstream Go source file: key/key.go
Upstream Target Tag / Version: v2.1.0
Types and functions for generating user-definable keymappings useful in Bubble Tea components. There are a few different ways you can define a keymapping with this package. Here’s one example:
use rusty_bubbles::key;
struct KeyMap {
up: key::Binding,
down: key::Binding,
}
fn default_key_map() -> KeyMap {
KeyMap {
// actual keybindings
up: key::new_binding(
key::with_keys(&["k", "up"]),
// corresponding help text
key::with_help("↑/k", "move up"),
),
down: key::new_binding(
key::with_keys(&["j", "down"]),
key::with_help("↓/j", "move down"),
),
}
}The help information, which is not used in the example above, can be used to render help text for keystrokes in your views.
Structs§
- Binding
- Binding describes a set of keybindings and, optionally, their associated help text.
- Help
- Help is help information for a given keybinding.
Functions§
- matches
- Matches checks if the given key matches the given bindings.
- new_
binding - NewBinding returns a new keybinding from a set of BindingOpt options.
- with_
disabled - WithDisabled initializes a disabled keybinding.
- with_
help - WithHelp initializes a keybinding with the given help text.
- with_
keys - WithKeys initializes a keybinding with the given keystrokes.
Type Aliases§
- Binding
Opt - BindingOpt is an initialization option for a keybinding. It’s used as an
argument to
new_binding.