#include<stdio.h>
int main()
{
int chr1, chr2;
printf("Press any arrow key...\n");
chr1 = getch();
if (chr1 == 0xE0) //to check scroll key interrupt
{
chr2 = getch(); //to read arrow key
switch(chr2)
{
case 72: printf("UP ARROW KEY PRESSED\n");
break;
case 80: printf("DOWN ARROW KEY PRESSED\n");
break;
case 75: printf("LEFT ARROW KEY PRESSED\n");
break;
case 77: printf("RIGHT ARROW KEY PRESSED\n");
break;
default: printf("OTHER KEY PRESSED: %d %d\n", chr1, chr2);
break;
};
}
return 0;
}
Output of program
Press any arrow key...
UP ARROW KEY PRESSED
doesn't work
ReplyDeletePl. share type of platform you are using to run this program. Also, share what error are you getting while running this program.
DeleteFor your information this program is running in my system with Windows 7, 32 bit version.
Thanks sir
ReplyDelete