Home > Software design >  How Do You Make Timed Keyboard Responds?
How Do You Make Timed Keyboard Responds?

Time:06-09

I want to make it so that the game will print and ask to type a certain letter, and if I don't then I lose What I want it to be like: Press E: (if you don't type it after 5 seconds, you lose. If you DO type it, the game will continue)

CodePudding user response:

Check out the keyboard library, and probably the time library too. I think the easiest way to do this is to create some sort of clock, save a "start time" (what time the prompt came up) and then enter a loop, exiting only when you have either pressed the key, or 5 seconds from the start time has elapsed. Make sure you keep track of which one actually happened.

  • Related