What is "Enter" key value?

Hai!

What is “Enter” key value? And where to put it(special func or keyboard func)?

Example: Ecs=27 (keyboard func)
Up Arrow=GLUT_KEY_UP (special func)
Enter=?? (?? func)

I hope this can be understand.

If it is a “keyboard func”, it must be 13.
tFz

Thanks Teofuzz

Err…How about space bar?

32 if I remember correctly.

Howdy,

yep, we could all throw ascii values around until the cows come home (or, until we’ve covered all 255 of them, and then we can move onto java’s 16bit character. heh heh)

You don’t need to do

char c;
if(c==(char)32)

because you can just do:

char c;
if(c=='
') { /* press ENTER' */ } 
else if(c==' ') { /* press SPACE' */ }
else if(c=='A') { /* press .. er... uhm... */
}

and so on. Also, if you REALLY want to know the magically cool keys, like the cursors, then you can easily write a simple program to print out the value your glut keyboard function is called with, and then just look at the numbers… =)

cheers
John

[This message has been edited by john (edited 05-28-2001).]

Hello!

Thanks to all. This really help me! But did all the keys has their ascii value? For example SHIFT key?

All keys that has a direct character mapped to it has an ascii code. Shift is a, uuh, what’s it called, dead/silent key (?). Never mind. Shift does not work alone, like ‘A’ and Enter. It has a scan code (the code generated by the keyboard which is, in turn, translated to a character), but no ascii code. This is why you have to use GLUT’s special key function.

Hai! This will maybe out off the original topic.

I create a first person camera walking in a world using the UP,DOWN,LEFT,RIGHT key. When the user press the ‘R’ key, the camera will move faster.

I use glutIgnoreKeyRepeat to make my app runs faster. Each time a key is pressed, it will return a TRUE value and when the key is released, it will return a FALSE value.

Here’s my pseudecode:

void keyboardPress(…)
{ if(key==‘R’)R_key_pressed=TRUE; }

void keyboardRelease(…)
{ if(key==‘R’)R_key_pressed=FALSE; }

void specialPress() {…}
void specialRelease() {…}

void idle()
{ int speed=10;
if(R_key_pressed)speed=20;
if(Up_key_pressed)moveMeFlat*speed;

glutPostRedisplay();
}

My question is, how can I change the ‘R’ key to SHIFT key? Can anybody show me the code?

Might Try VK_SHIFT or I DONT KNOW WHAT THIS IS REALLY FOR but it might work GLUT_ACTIVE_SHIFT