Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <conio.h>
- #include <stdio.h>
- const int EXTENDED_KEY = 0xE0;
- const int ARROW_UP = 'H';
- const int ARROW_DOWN = 'P';
- const int ESCAPE = 0x1B;
- int main(){
- for (;;) {
- int ch = _getch();
- if (ch == 0 || ch == EXTENDED_KEY) {
- int ch2 = _getch();
- if (ch2 == ARROW_UP) {
- printf("Up\n");
- } else if (ch2 == ARROW_DOWN) {
- printf("Down\n");
- } else {
- printf("Extended key: %d %x %c\n", ch2, ch2, ch2);
- }
- } else {
- printf("Regular key: %d %x %c\n", ch, ch, ch);
- }
- if (ch == ESCAPE) {
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement