with
WaitForMultipleObjects[
^] you can wait two events or more, one is a small thread doing only "read character" and the other could be a Waitable timer, and/or a "cancel button" GUI thread.
But there is a lot of traps with such kind of code, I very strongly encourage you to use a library such as
boost asio[
^]