strategem-hero 0.4.0

Simple CLI Game following Strageme Hero mini-game from Helldivers 2
use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind};

#[derive(Debug)]
pub enum Key {
    ArrowUp,
    ArrowDown,
    ArrowLeft,
    ArrowRight,
    Escape,
}

pub fn read() -> std::io::Result<Option<Key>> {
    match crossterm::event::read()? {
        Event::Key(KeyEvent {
            code: KeyCode::Up,
            kind: KeyEventKind::Press,
            ..
        }) => Ok(Some(Key::ArrowUp)),
        Event::Key(KeyEvent {
            code: KeyCode::Down,
            kind: KeyEventKind::Press,
            ..
        }) => Ok(Some(Key::ArrowDown)),
        Event::Key(KeyEvent {
            code: KeyCode::Left,
            kind: KeyEventKind::Press,
            ..
        }) => Ok(Some(Key::ArrowLeft)),
        Event::Key(KeyEvent {
            code: KeyCode::Right,
            kind: KeyEventKind::Press,
            ..
        }) => Ok(Some(Key::ArrowRight)),
        Event::Key(KeyEvent {
            code: KeyCode::Esc,
            kind: KeyEventKind::Press,
            ..
        }) => Ok(Some(Key::Escape)),
        _ => Ok(None),
    }
}