use std::io; use std::thread; use std::time; use lb::term; use lb::term::key; use lb::term::key::Key; fn main() { println!("Chars {:?}", term::size()); println!("Pixels {:?}", term::size_in_pixels()); let _raw = term::uncook().unwrap(); print!("\r\nPress any key. Press q, ^C, or Esc to quit.\r\n"); let mut stdin = io::stdin(); let buf = &mut [0u8; 32]; 'outer: loop { let keys = key::Keys::new(&mut stdin, buf).unwrap(); print!("{:?} ", keys.bytes()); for key in keys { match key { Key::Char(b'q' | b'\x03') | Key::Esc => break 'outer, Key::Char(byte) => print!("{}, ", byte as char), Key::Up => print!("Up, "), Key::Down => print!("Down, "), Key::Left => print!("Left, "), Key::Right => print!("Right, "), } } print!("\r\n"); thread::sleep(time::Duration::from_millis(333)); } }