Archived

This topic is now archived and is closed to further replies.

glut keys

This topic is 6036 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

where can i find a listing of what all the keys #''s are. i know 27 is (esc), but i need to know some other, like the arrow keys, and ctrl/shift/alt home.earthlink.net/~eberkain/

Share this post


Link to post
Share on other sites
You can look in the header file. GLUT has a function for getting the status of some keys like ctrl. I think the name is glutGetModifier.

Share this post


Link to post
Share on other sites
Arrow keys and keys like Page Down/Page Up/Home/End are handled in a different function that normal keyboard commands. Ordinarily, keys like 'a' and 'b' would be directed to the function you provide in the glutKeyboardFunc(...) function, they're going to go to the function in the glutSpecialFunc(...) command.

For example, here's how I handled that problem...

  
void keyboard2GL(int key, int x, int y)
{
if(key == GLUT_KEY_LEFT) xdir -= 2.0f / zoom;
else if(key == GLUT_KEY_RIGHT) xdir += 2.0f / zoom;
else if(key == GLUT_KEY_DOWN) ydir -= 2.0f / zoom;
else if(key == GLUT_KEY_UP) ydir += 2.0f / zoom;
else if(key == GLUT_KEY_HOME) {xdir -= 2.0f / zoom; ydir += 2.0f / zoom;}
else if(key == GLUT_KEY_END) {xdir -= 2.0f / zoom; ydir -= 2.0f / zoom;}
else if(key == GLUT_KEY_PAGE_UP) {xdir += 2.0f / zoom; ydir += 2.0f / zoom;}
else if(key == GLUT_KEY_PAGE_DOWN) {xdir += 2.0f / zoom; ydir -= 2.0f / zoom;}
}

void createWindow(void* arg)
{
// Code goes here...

glutKeyboardFunc(keyboardGL);
glutSpecialFunc(keyboard2GL);
// More code goes here...

glutMainLoop();
}


Hope this helps! :D

~ Dragonus

Edited by - Dragonus on July 9, 2001 4:37:48 PM

Share this post


Link to post
Share on other sites