Receiving an input

When i run my program, one of the requirements is to be able to accept an input at any time. EG: If the user presses escape at ANY time of the program. The program should go back to the main menu. I dont think using a function to check if escape is entered at every input screen would be the most efficient method.PLZ help...
P.S I use Code::Blocks
I'd guess that 'any time' means when the user should respond to whatever menu?

Following suggestion:

Make an array of menus (ie the text that should appear).
Make a function that shows the menu according to the index.
Make a second array (2d) that maps the user input to the next menu shown. The action taken can also be determined by the index.

So you could determine that ESC always leads to menu 0.
thnx coder777 :D . but i still dont understand as to how the program will be prepared to receive 'escape' as an input even during run time.
EG: In a videogame whenever we want to exit the game we press 'escape' at that time a menu shows up asking the user if he wants to quit the game or not.
I am trying to use that concept in my programme.
threads are usually used to be able to check for user input while other things are running. however, you'll need c++ 11 for that or to use libraries like boost
have you tried using
getasynckeystate(VK_)
Last edited on
Topic archived. No new replies allowed.