Beginner question read char in console without pressing enter


#1

Hi, I’m learning the basics of Rust and trying to capture a keypress for a simple console app. More specifically, I want to capture the arrow up|right|down|left keys. In C/C++ I would use something like the ´getchar´ function inside a while-loop.

I couldn’t find any similar way to do this in Rust. Instead I found this but it seems very complicated https://stackoverflow.com/questions/26321592/how-can-i-read-one-character-from-stdin-without-having-to-hit-enter.

Any ideas?
Thanks in advance :slight_smile:


#2

Hi! Look at console crate, maybe it’d help you? Here’s how it is used.