Created
November 17, 2021 18:53
-
-
Save 3rt4nm4n/2f25573f4efb8ba6474b7ff88915cac2 to your computer and use it in GitHub Desktop.
This is a C++ program that will detect Left, Up, Right and Down arrow keys when they are pressed, it will give outputs. The program may give such outputs like [[A^, these are raw key codes that are sent by computer to the terminal.
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> for windows users who will use getch() in switch condition | |
using namespace std; | |
int main() | |
{ | |
char ch; | |
switch(scanf(&ch)) | |
{ | |
case 37: | |
cout<<"Left Button"<<endl; | |
break; | |
case 38: | |
cout<<"Up Button"<<endl; | |
break; | |
case 39: | |
cout<<"Right Button"<<endl; | |
break; | |
case 40: | |
cout<<"Down Button"<<endl; | |
break; | |
default: | |
break; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment