Change settings -> Terminal -> Features -> Disable application keypad mode
see the picture below:
2014/02/26
2014/02/25
2014/02/16
[C]方向鍵輸入判斷
#include <stdio.h>
#include <conio.h>
int main()
{
char ch1, ch2;
while(ch1 = getch())
{
if(ch1 == -32)
{
ch2 = getch();
if(ch2 == 72)
printf("up key press\n");
if(ch2 == 75)
printf("left key press\n");
if(ch2 == 77)
printf("right key press\n");
if(ch2 == 80)
printf("down key press\n");
}
}
return 0;
}
#include <conio.h>
int main()
{
char ch1, ch2;
while(ch1 = getch())
{
if(ch1 == -32)
{
ch2 = getch();
if(ch2 == 72)
printf("up key press\n");
if(ch2 == 75)
printf("left key press\n");
if(ch2 == 77)
printf("right key press\n");
if(ch2 == 80)
printf("down key press\n");
}
}
return 0;
}
2014/02/01
訂閱:
文章 (Atom)