keyboard

I want to if a certain combination of keys were pressed(for example, if the UP and RIGHT arrow keys have been pressed).How do
I do that?

Use GLFW.

or SDL

or glut :slight_smile:

Can you really do this with glut?


void KeyFunc (unsigned char key, int x, int y)
{
   switch (key){
      case 27:
	 exit (0);
      case 's':
	 Snapshot();
	 break;
   }
}

...
glutKeyboardFunc (KeyFunc);

I know that, but how do I test if 2(two) keys are pressed in the same time?(ex: UP and RIGHT keys are pressed simultaneously)

“HOWTO: Check if a Key is Down” http://www.nullterminator.net/glut.html

But really, for this kind of things, GLFW is really really much easier.

Jesus. Are you serious?

Use some 2 boolean variables and set them when the keys change their state, you can use them as conditions later on…