Last active
January 22, 2025 12:54
-
-
Save upsilun/3b51541a9a7fc96144331bba25f79348 to your computer and use it in GitHub Desktop.
Getting pressed keyboard key in ASCII code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <conio.h> | |
using namespace std; | |
int main() { | |
char ch; | |
while(true) { | |
if(_kbhit()) { // check if key has been pressed | |
ch = _getch(); | |
cout << "Key pressed: " << (int)ch << endl; // print ASCII code of key | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment