Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <iostream>
- using namespace std;
- #define KEY_UP 72
- #define KEY_DOWN 80
- #define KEY_LEFT 75
- #define KEY_RIGHT 77
- #define KEY_ESC 27
- int main()
- {
- int c = 0;
- while(1)
- {
- //c = 0;
- switch((c=getch())) {
- case 224:
- break;
- case KEY_ESC:
- cout << "Quit" << endl; //key up
- exit(0);
- case KEY_UP:
- cout << "Up" << endl; //key up
- break;
- case KEY_DOWN:
- cout << "Down" << endl; // key down
- break;
- case KEY_LEFT:
- cout << "Left" << endl; // key left
- break;
- case KEY_RIGHT:
- cout << "Right" << endl; // key right
- break;
- default:
- cout << "null (" << c << ")" << endl; // not arrow
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement