[英]If loop that executes when Enter key is pressed C++
I'm using Windows XP Home Edition. 我正在使用Windows XP Home Edition。 I want to set up a menu system that displays an image when the Enter key is pressed.
我想设置一个菜单系统,当按Enter键时显示图像。 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.
有什么方法可以设置一个if语句,该语句在不设置GUI的情况下在按下键盘上的Enter键时执行。 For example, can I just use the hex value associated with Enter key as a trigger for the if statement.
例如,我可以仅使用与Enter键关联的十六进制值作为if语句的触发器。
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: 对于Windows,您可以使用几种变体来实现此目的:
std::getline
and discard the input. std::getline
并丢弃输入。 _kbhit
and _getch
to check for the Enter key. _kbhit
和_getch
来检查Enter键。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.