Listening to Multiple Key Events simultaneously

Hello, I am currently developing a game. I have finished nearly all the programming involved, however, I still have a problem concerning Dual-Player - I would like to be able to listen to several keystrokes simultaneously so that each player would be able to move whilst the other player is performing a move himself.

PS - I am currently keeping track of events using an EventQueue of myself, which I "pushed" into the SystemEventQueue.

With Thanks,

laginimaineb.

[488 byte] By [laginimaineba] at [2007-11-26 21:59:58]
# 1
What's the problem? Is it the obvious fundamental problem that a queue only lets you pop things one at a time, or are you finding that keystrokes are lost?
YAT_Archivista at 2007-7-10 3:59:26 > top of Java-index,Other Topics,Java Game Development...
# 2

Thanks for your reply. Yes, my problem is that queues only process one at a time. What I am looking for is a way to listen to simultaneous KeyEvents. I understand this is not possible via EventQueue and therefore I am free to any suggestions. By the way, another problem is that once one key is pressed, it keeps firing KeyEvents and all other keys which are also pressed stop firing KeyEvents. Is there a way around that or should I just keep track of all keys which are pressed until I receive an Event telling me that they were released?

With Thanks,

laginimaineb.

laginimaineba at 2007-7-10 3:59:26 > top of Java-index,Other Topics,Java Game Development...
# 3

What I do is to have a set of booleans, one for each key used in the game. I set them to true in keyPressed() and false in keyReleased(), then I handle the booleans in the run() loop, so multiple keypresses aren't a problem;

if (m_leftPressed && m_jumpPressed) doSomething();

Simon__1sta at 2007-7-10 3:59:26 > top of Java-index,Other Topics,Java Game Development...
# 4
I wrote an example for this a while ago, knock yourself out: http://woogley.net/misc/MultiKey/
Woogleya at 2007-7-10 3:59:26 > top of Java-index,Other Topics,Java Game Development...
# 5
Thanks for both replies, they were very helpful. This solved my problem.With Thanks,laginimaineb.
laginimaineba at 2007-7-10 3:59:26 > top of Java-index,Other Topics,Java Game Development...