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')) //不支持大小 ...
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 }