I've combined several answers here to a solution that reads characters from
console
file
pipe
with timeout and runs on
windows
linux
cygwin
https://github.com/majorkingleo/read_from_stdin/blob/main/src/read_from_stdin.cc