PDA

View Full Version : ASCII values for arrow keys



Eclipix
05-02-2002, 11:31 AM
So, does anyone know the values used for the arrow keys, i don't think that they are ASCII but maybe they are. Oh, and anyone know of any tuts on glaux.h?

nexusone
05-02-2002, 12:09 PM
If you use glut for your keyboard input they are definded under glutSpecialFunc() as GLUT_KEY_DOWN, GLUT_KEY_UP and GLUT_KEY_LEFT AND GLUT_KEY_RIGHT.


On glaux, ton's of stuff on it, just do a search. But glaux library is out dated and should not be used. glaux was replaced by the glut library, the glut library has functions that where in the glaux, except the BMP loading function.


Originally posted by Eclipix:
So, does anyone know the values used for the arrow keys, i don't think that they are ASCII but maybe they are. Oh, and anyone know of any tuts on glaux.h?

kabir
05-02-2002, 01:13 PM
You're right... they're not ASCII. What you're after are key codes. In the case of microsoft they are virtual key kodes (VK_UP, VK_LEFT, etc.). The reason that they're not ASCII codes is that they have a wide variety of meanings... really what you're after is the keypress event, not the character (if any) which it was mapped to by the OS (which might be none, or many).

gumby
05-02-2002, 06:52 PM
Hmm, the letter 'a' can have many meanings
also :}

Brent Fogarty
05-02-2002, 07:02 PM
The arrow keys are part of the extended keyboard so they return extended key codes. In english that means that when you press one of them it actually returns two key codes, the first is allways 0 then the next is the actual key code. The reason for this is that the key codes for the arrow keys are the same as some of the letter keys. So when you get a key code of 0 you no to get another key code and use it eg.

if ( getch() == 0 )
{
ch = getch();

if ( ch == 85 ) //up I think
do something...
}
else
normal key...

All this said if your working in win32 then all of what I have said is useless and use the key codes:
VK_LEFT
VK_UP
VK_DOWN
VK_RIGHT