Wait for a user input for a certain period of time?

Suppose i have a loop which waits for a user input only for a small period of time and continues executing the rest of the body of the loop once this time frame is over? How would i write the code for this?

Like in the all famous 'Snake' game, the snake keeps moving in one direction unless the user presses the left or right buttons.
Topic archived. No new replies allowed.