MCPcopy Create free account
hub / github.com/algoscienceacademy/RustUI / from_key_event

Method from_key_event

src/event.rs:26–37  ·  view source on GitHub ↗
(key: KeyEvent)

Source from the content-addressed store, hash-verified

24
25impl Event {
26 fn from_key_event(key: KeyEvent) -> Self {
27 use crossterm::event::KeyCode as TermKeyCode;
28 let code = match key.code {
29 TermKeyCode::Char('q') => KeyCode::Q,
30 TermKeyCode::Up => KeyCode::Up,
31 TermKeyCode::Down => KeyCode::Down,
32 TermKeyCode::Left => KeyCode::Left,
33 TermKeyCode::Right => KeyCode::Right,
34 _ => return Event::KeyPress(KeyCode::Q),
35 };
36 Event::KeyPress(code)
37 }
38}
39
40#[derive(Clone, Copy, Debug)]

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected