Please specify machine and operating system.
Main Topics
Browse All TopicsHi! I need the codes for the keys "End" and "PageDown". They're not on the ASCII table. When I type "man ascii" they're not mentioned on the list.
I need to treat these keys and I don't know how to treat special keys.
Thanks.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
The reason they're not in an ASCII table, is that they're not ASCII keys. Imladris is right - it's a system dependant thing. On most machines a two-key code is generated, this is shown in fviellet's answer for a Unix terminal. On most PCs the BIOS will generate a 0 for what are known as the 'extended' ASCII keys, as a flag showing that there will be another byte, and then the values for the extended keys.
Well you add 256 to the keycode. It works somewhat like this:
The keyboard returns a 16 bit string, of which one byte is your ascii code. The zero is merely because this information is in the other byte.
So you read in two chars, if the first is zero check keycode of second, else first is desired key. I did this on dos.
Else you can read in the full int value and decide.
end = 256 + 79 = 335, and so on.
This is getting interesting as it goes... Thank you, DVB. I'll try it tonight and then feed back you all.
I'm a C programmer, but the reason why I'm so interested in these codes right now is that DOOM for Linux uses a file called
~/.doomrc
for it's configuration. I have to supply the keycodes in ASCII on this file to map the keyboard.
If this doesn't work now, I'll try to find a DOS/Windows machine to install DOOM and run the "SETUP.EXE" application, that is much more friendly and writes a configuration file, I believe it's 'default.cfg'. It's the equal to the '~/.doomrc' file.
try this program this works!!!
int readkey(int *is_function_key)
{
int c;
*is_function_key=0; //assume normal key is pressed
c=getch(); // no echo on the screen
if (c==0)
{
c=getch(); //the ascii code of the key
*is_function_key=1; //yes! this looks suspicious
}
return(c);
}
write this funtion in your main program and call it as follows
c=readkey(&is_pgdn);
compare c with the ascii values of the pgdn (they are already given by others!! so no need to repeat) and is_pgdn with `1'. you're on!!!
I won't be able to evaluate this solution now. I've changed my on-board SiS 5598 for a Trident 9680 and my DOOM stopped working. It's strange, as Quake continued to work. DOOM now has a crappy screen and when I leave it, the console is trashed, filled with error colorful characters. I can't even restore it with the 'reset' command. Fortunatelly I've mapped CTRL+ALT+DEL to 'shutdown -h now', so I can make a clean exit in the system.
Business Accounts
Answer for Membership
by: fveilletPosted on 1999-10-06 at 06:42:53ID: 2103278
If you're using a VT220 terminal emulator or the like, these keys are Control Sequences. The usually are a combinaison of the Escape keyes followed by several other keys.
You can easily find descriptions of these key sequences in VT220 documentation for programmers.
Also an easy way to find a sequence is with the "cat" command. Like this:
$ cat >seq
<Type the key>
<CTRL-D>
$ vi seq
Now you should see the complete key sequence. As I said, usually starting with Escape key, displayed as ^[
Hope this helps.