Termion raw mode not returning events until \n

For some reason, termion is not returning from next() until [enter] is pressed. By necessity, I need next() to return after each key is pressed. Thus, I use raw mode, but it doesn't seem to work. Why might this be? Is this a termion bug?

fn spawn_input_listener(mut input_tx: tokio::sync::mpsc::Sender<String>, ctx: ConsoleContext) {
    std::thread::spawn(move || {
        let mut iter = std::io::stdin().events_and_raw();
        loop {
            while let Some(key) = iter.next() {
                if let Ok(key) = key {
                    match key.0 {
                        termion::event::Event::Key(termion::event::Key::Backspace) => {

                        termion::event::Event::Key(termion::event::Key::Char('\n')) => {
                            if !INPUT_ROUTER.send_internal_buffer(&mut input_tx) {
                                log::warn!("Error sending input. Closing program");

                        termion::event::Event::Key(termion::event::Key::Char(val)) => {

                        _ => {}

Using Ubuntu/WSL

Solution: enable raw mode for the terminal. Unfortunately, WSL seems bugged when raw mode is enabled (prints to stdout look malaligned, poorly formatted, when using prettytable or clap output)

let terminal = std::io::stdout().into_raw_mode().unwrap();

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.