Read one char from stdin without pressing enter (getch)

Terminals don’t send data until enter is pressed. This is called canonical mode. you can change this behavior by taking the terminal out of canonical mode, but that is usually done in the context of a TUI app.

If you pipe input from a file into your process stdin, I think you’ll see the behavior you are looking for.