Multiple Keys down in SDL - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Multiple Keys down in SDL (/thread-1221.html)
Multiple Keys down in SDL - silver9172 - May 30, 2009 12:05 PM
I am working on basic input functions in SDL and have run into a problem. I want user's to be able to press ALT - ENTER and have the program go into full screen. I have started to write the function but can not get it to recognize when I press the second key. Heres what I have:
I tried putting another switch after the ALT key is down but it doesn't see it. What do I need to do here to get this to work?
Multiple Keys down in SDL - ThemsAllTook - May 30, 2009 01:06 PM
You can rely on your user input API to tell you when individual keys are pressed and released, but beyond that, you'll need to keep track of their state yourself. Keep boolean variables for each key you care about, set them to true when the key is pressed, set them to false when they're released, and take action based on the state of your booleans.
Multiple Keys down in SDL - scgames - May 30, 2009 06:16 PM
You might be able to use the 'mod' field of the SDL keyboard event structure for this as well (IINM, it will represent the state of the modifier keys at the time the event was dispatched).
Note also that you'll probably want to process your events using a 'while' loop rather than an 'if' statement; otherwise, you may not consume all the events that are pending for that update, which may cause your app to appear unresponsive.