GetAsyncKeyState 获取键盘按键消息
1 #include <Windows.h> 2 #include <iostream> 3 using namespace std; 4 5 int main() 6 { 7 while(true) 8 { 9 if(-32767 == GetAsyncKeyState('A')) //不支持大小写识别 10 { 11 cout<<"您按下A键"<<endl; 12 } 13 if(-32767 == GetAsyncKeyState('B')) 14 { 15 cout<<"您按下B键"<<endl; 16 } 17 if(-32767 == GetAsyncKeyState(VK_RETURN)) 18 { 19 cout<<"您按下回车键"<<endl; 20 } 21 } 22 return 0; 23 }
浙公网安备 33010602011771号