View Full Version : Two keys pressed, GLUT

02-14-2004, 01:37 PM
Hello, i'm using GLUT 3.7
with the KeyboardFunc call i call a function which recieves only 1 key, and two coordinates (x,y). how can i make my program deal with more than one key pressed at a time?
let's say i have a model rendered and i would like to move it both up and left (diagonaly). when i press up it goes up but as soon as i press the left button while the up is pressed - it moves only to the left...

hope you can help...

02-14-2004, 08:51 PM
Firstly, Id advice against using GLUT for much beyond simple demos... But anyway.
What you have to do, is account for both KeyUp and KeyDown events. So when a key is pressed, you mark it as pressed, and then when that key is released, a keyup event will be issued by glut, and just mark that key as not pressed.
At the moment your probably only using the keydown event, which is why you cant handle more than 1 key at a time.

[This message has been edited by MrShoe (edited 02-14-2004).]

[This message has been edited by MrShoe (edited 02-14-2004).]