I have a background thread that reads bytes in an infinite loop and sends them to main through a channel
. I'm looking for the equivalent of C's getch()
.
I found this:
let byte = io::stdin().bytes().next().expect("no byte read").ok().unwrap();
This waits for an Enter which I don't want. It also prints the inputted character, which is also unwanted.
After I press Enter, I get all the characters I pressed one by one and finally instead of just a 10 (new line), I get 10 followed by 13. Why?