Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return Codes

Status
Not open for further replies.

Spannerman

Programmer
Dec 31, 2000
26
GB
What are the Return Codes in C for the arrow keys?
 
Examine the code below on how to get the extended key codes:

int main(){
int a;

printf("Press escape to quit!\n\n");
while(1)
{
a = getch(); /* Get key press and */
if (a == 0 ) { a = getch() + 0x100; } /* Add 256 if extended */
switch ( a )
{
case 27: /* If escape key */
printf( "Escape key. Exiting...\n" );
return 0;
case 328: /* If Up Arrow key */
printf("Up Arrow key\n");
break;
case 336: /* If Down Arrow key */
printf("Down Arrow key\n");
break;
case 333: /* If Right Arrow key */
printf("Right Arrow key\n");
break;
case 331: /* If Left Arrow key */
printf("Left Arrow key\n");
break;
default:
printf("Key code is --> %d\n", a);
}
}
}



Kim_Christensen@telus.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top