检查ALT键是否被按下
问题描述:
经过大量测试后,我无法记录在C程序中是否使用GetAsyncKeyState按下Alt键。 当我试试这个:检查ALT键是否被按下
if (GetAsyncKeyState(VK_SHIFT))
// do something
它可以正常工作,但是当我尝试这个
if (GetAsyncKeyState(VK_MENU))
// do something
它不工作。
所以我的问题是“我如何记录ALT?”。
在此先感谢
答
我用下面的代码,以找出完全符合GetAsyncKeyState
任何键值,我认为这是18关键。
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#if _WIN32_WINNT < 0x0500
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0500
#endif
#include <windows.h>
using namespace std;
int main()
{
char i;
for(i=8; i<190; i++)
{
if(GetAsyncKeyState(i)== -32767)
{
cout<<int (i)<<endl;
}
}
return 0;
}
感谢您的回答 –
欢迎您@FedericoLolli :) – Roy