欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

GetAsyncKeyState 获取键盘按键消息

程序员文章站 2022-03-18 16:55:56
1 #include 2 #include 3 using namespace std; 4 5 int main() 6 { 7 while(true) 8 { 9 if(-32767 == GetAsyncKeyState('A')) //不支持大小 ......
 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 }