console-input 0.2.0

A simple library to help handle keyboard presses in a console
Documentation
//! Will tell you what key you pressed immediately after you press it, without the need to press enter

use console_input::{
    keypress::{self, read_and_handle_kb_interrupt},
    printr,
};
use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind};

fn main() {
    keypress::enable_raw_mode();

    loop {
        let Some(Event::Key(key_event)) = read_and_handle_kb_interrupt(true) else {
            continue;
        };

        match key_event {
            KeyEvent {
                code: KeyCode::Char(char),
                ..
            } => printr!("You pressed the {} key!", char),
            KeyEvent {
                code: KeyCode::Enter,
                kind: KeyEventKind::Press,
                ..
            } => printr!("You pressed enter!"),
            _ => (),
        }
    }
}