#back-end #ratatui #ratatui-event-input

ratatui-eventInput

Unify input from diffrent ratatui backends

6 releases

0.2.0 Feb 24, 2025
0.1.4 Jan 7, 2025
0.1.2 Dec 25, 2024

#93 in #ratatui

Download history 270/week @ 2024-12-22 121/week @ 2024-12-29 113/week @ 2025-01-05 9/week @ 2025-01-12 1/week @ 2025-02-09 1/week @ 2025-02-16 100/week @ 2025-02-23 17/week @ 2025-03-02 1/week @ 2025-03-09

582 downloads per month

MIT license

19KB
412 lines

ratatui-eventInput

Unifies input handling from crossterm, termion and termwiz.

It is meant to be used by ratatui libraries to make input handling easier, or allow people using a library to specify what input to listen to.

Basic usage

The default backend is crossterm, if you want to use a different one you need to enable the feature for it:

ratatui-eventInput = {
    version = "0.1", 
    features = [
        "crossterm", 
        "termion", 
        "termwiz"
    ] }

After that just use a function like this to handle the input:

use ratatui_eventInput::{Input, Key};

pub fn handle<I: Into<Input>>(&mut self, input: I) {
    let input: Input = input.into()
    if input.key == Key::Right {
        println!("right")
    } else if input.key == Key::Left {
        println!("left")
    }
}

Acknowledgments

This library does not support all inputs the backends give and is mostly based on the inputs that crossterm uses.

Dependencies

~3–15MB
~226K SLoC