[question] async_stdin and keys()
Hi,
I noted that while being in async_stdin
"mod" the keys()
method does not return proper events. For example if I use the code below, Left
key is not recognized. If I use let mut it = stdin.keys()
instead of termion::async_stdin()
this works well. Can someone explain me why ?
use std::io;
use std::io::{stdin, stdout, Read, Write};
use termion;
use termion::event::Key;
use termion::input::TermRead;
use termion::raw::IntoRawMode;
fn main() -> Result<(), io::Error> {
let mut stdout = io::stdout().into_raw_mode()?;
let mut stdin = termion::async_stdin();
// let mut stdin = io::stdin();
let mut it = stdin.keys();
loop {
let b = it.next();
if let Some(event) = b {
match event? {
Key::Left => println!("LEFT"),
Key::Char('q') => break,
_ => {}
}
}
stdout.flush()?;
}
Ok(())
}