I don't think there's a standard way to do this. I would look into using an event library that can generate an event at a specific time. Then you can write things that need to happen as event handlers, such as your timeout.
If you want to perform your own event handling or if your needs are simple you can create a simple "forever" loop that checks for the various events you are interested in like keyboard and timeouts and then reacts to them accordingly.
Code:
for (;;) {
// check for and handle keyboard presses
// TODO
// check the current time to see if a timeout has occured
// TODO
// redraw or update the screen
// TODO
// yield some processor time to the operating system
usleep(100);
}
To check for keyboard presses you can use an OS-specific method, as there is no standard method for this. I would recommend curses to keep your code portable.
For updating the screen again probably an OS-specific method is in order.
For checking the time there is gettimeofday.