我有一个C ++程序,必须检测空格键,该怎么办?我看到我需要该功能getch()
,但是在我的程序中却没有conio.h
。是否存在其他解决方案?
随着getchar
我需要按intro
,存在其他形式,我只按下空格键?
例如,我可以intro
不按引入intro
???吗?
简单的例子
#include <iostream>
using namespace std;
int main()
{
char ans;
do
{
//code
}
while(getchar() != 32 || getchar() != ' ');
cout << "Space pressed" << endl;
return 0;
}
Windows.h:
if(GetAsyncKeyState(VK_SPACE) & 0x80000000)
MessageBox(NULL, "Spacebar pressed!", "TEST", MB_OK);
看不到conio.h
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句