问题描述
我目前正在Windows中开发各种控制台游戏,使用 cin
的常规输入无法使用。
我如何(以简单的方式只使用MSVC中提供的标准窗口库):
-
使程序等待(特定?)键按下并返回键ID(必须对所有键(包括箭头键)起作用)
- p>在实时游戏期间检查用户的最后一次按下的键,以及自上次检查后是否按下任何键。
如果您可以为您的解决方案包括一个简短的示例程序,它真的会有帮助。
使用标准C运行时。您将需要使用某些功能,如Win32函数。
I'm currently developing various console games in Windows that won't really work using regular input via cin
.
How can I (In a simple way using only standard windows libraries available in MSVC):
Make the program wait for a (specific?) key press and return the key ID (It would have to work for all keys including the arrow keys)
During a real-time game check for the last pressed key of the user and if there was any key pressed since the last check.
It would really help if you could include a short example program for your solution
AFAIK you can't do it using the standard C runtime. You will need to use something such as the Win32 function GetAsyncKeyState.
这篇关于Windows控制台中的C ++键输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!