Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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.
 
Share this answer
 
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900