for using arrow keys, first it has to be stored for analyzing it. That's why I am using scanf
to store it.
But when I try to run this code, and when I press up key, then it is showing ^[[A
and when I press enter then this ^[[A
removes and program exit without printing printf statement of printf("%s",c).
and printf("UP\n").
#include <stdio.h>
int main()
{
char c[50];
scanf("%s",&c);
printf("%s",c);
if (getch() == '\033'){ // if the first value is esc
getch();// skip the [
getch();// skip the [
switch(getch()) { // the real value
case 'A':
printf("UP\n");
break;
case 'B':
printf("DOWN\n");
break;
}
}
return 0;
}