View Full Version : Simultaneous key presses

06-14-2000, 01:03 AM

I'm currently coding a 3D engine in C and using GLUT to maintain maximum portability.

How do you allow for simultaneous key presses? For example, when I'm moving forward and then I want to strafe, I need to press the 'forward' button, let go, then press 'strafe' button. is there a way to handle button presses better without having to let go?

also, is there a platform-independent way to detect if you have RELEASED a key button? this would be very helpful to trigger deceleration in a 3D engine so your player doesn't just stop instantaneously.


06-14-2000, 06:04 AM
Q2: use glutKeyboardUpFunc()

Q1: I've never had any problems with simultaneous keypresses in GLUT. Just associate a flag with each control key, set it to true in glutKeyboardFunc and to false in glutKeyboardUpFunc(). Then base your movement on the combination of the various key flags.

06-14-2000, 11:59 AM
thanks a lot for your help. much appreciated.

btw, how did you know about glutKeyboardUp()?

i did not find that in the GLUT API.


06-15-2000, 04:30 AM
Heh... get into the habit of reading the headers. The GLUT API docs aren't particularly up-to-date.