You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
857 B
45 lines
857 B
#include <stdio.h> |
|
#include <conio.h> |
|
|
|
int get_key() |
|
{ |
|
int c=getch(); |
|
switch(c) |
|
{ |
|
case 0: return getch()+256; |
|
case 224: return getch()+512; |
|
} |
|
return c; |
|
} |
|
|
|
int main(int argc, char const *argv[]) |
|
{ |
|
int key = 0; |
|
for(;;) |
|
{ |
|
if (kbhit()) |
|
{ |
|
key = get_key(); |
|
printf("\n%d", key); |
|
switch (key) |
|
{ |
|
case 584: |
|
printf("\n↑"); |
|
break; |
|
case 592: |
|
printf("\n↓"); |
|
break; |
|
case 587: |
|
printf("\n←"); |
|
break; |
|
case 589: |
|
printf("\n→"); |
|
break; |
|
|
|
default: |
|
break; |
|
} |
|
} |
|
} |
|
return 0; |
|
}
|
|
|