简体   繁体   中英

If loop that executes when Enter key is pressed C++

I'm using Windows XP Home Edition. I want to set up a menu system that displays an image when the Enter key is pressed. Is there any way I can set up an if statement that executes when the Enter key is pressed on the keyboard without setting up a GUI. For example, can I just use the hex value associated with Enter key as a trigger for the if statement.

I've looked into reading input buffers. Am I going to have to get that complex with it? I don't really

For windows there are a couple of variants you could use to implement this:

  1. The standard way would be to call eg std::getline and discard the input.
  2. A more Windows-specific solution is to use eg _kbhit and _getch to check for the Enter key.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM