PDA

View Full Version : keyboard



Sergiu
02-16-2009, 07:31 AM
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?

ZbuffeR
02-16-2009, 08:27 AM
Use GLFW.

_NK47
02-16-2009, 10:54 AM
or SDL

-Ekh-
02-16-2009, 02:10 PM
or glut :)

Sergiu
02-17-2009, 06:28 AM
Can you really do this with glut?

-Ekh-
02-17-2009, 06:46 AM
void KeyFunc (unsigned char key, int x, int y)
{
switch (key){
case 27:
exit (0);
case 's':
Snapshot();
break;
}
}

...
glutKeyboardFunc (KeyFunc);

Sergiu
02-17-2009, 07:26 AM
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)

ZbuffeR
02-17-2009, 09:17 AM
"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.

IneQuation.pl
02-17-2009, 04:01 PM
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)
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...