keymap-rs
keymap-rs is a library for defining input events from configurations and mapping them to the terminal library's event. (such as crossterm or termion)
Getting started
Please check the examples directory for complete examples.
[]
= "0.1"
Let's started by defining a simple structure for mapping input key to String.
use ;
use Deserialize;
let config = r#"
up = "Up"
down = "Down"
g = "Top"
G = "Bottom" # This is the same as `shift-g`
esc = "Quit"
"
Then in your terminal library of choice (we'll be using crossterm as an example). You can use any deserializer (e.g. toml, json, etc.) to deserialize a key from the configuration above into the terminal library's event (e.g. crossterm::event::KeyEvent).
let mapping: Config = from_str.unwrap;
// Read input event
match read?