Click here to Skip to main content
14,334,439 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hii,

ASCII for the delete key is not working in my C code.
I tried this...

int c;
c=getch();
if(c==127)
{
     printf("\nPressed Delete Key");
}
else
{
    printf("\n Not Delete Key");
}
getch();
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Look at the MDSN documentation about ASCII characters: ASCII Character Codes Chart 1[^]

They state: "ASCII code 127 has the code DEL. Under MS-DOS this code has the same effect as ASCII 8 (BS). The DEL code can be generated by the CTRL + BKSP key."

I tried your code on my computer (Windows Vista 32 bit), and I found this:


  • the BACKSPACE key produce the code 8;
  • the DELETE key produce the code 224;
  • the CTRL + BACKSPACE key produce the code 127.
   
Comments
Dalek Dave 22-Oct-10 3:41am
   
Good Answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100