I wrote a little game where up to 4 players candrive a little car and play against the other players.You can use four keys to steer the car and twokeys to shoot some nasty little bullets (from a pneumatic stapler for example).It works really well with different maps and special effects and runswith up to 60 fps with Fullscreenmode.

The big problem is that sometimes the keyevents don't do what they should do.The game should be played on one keyboard and even with only two playerserrors already occur.Sometimes when I realease the firekey, it keeps on firingor I can't steer left or the other player is accelerating although he released the key.

If you don't understand any of the code, please ask.The smoothSteering is just so that the player has bettercontrol of small angles.int[][] keys contains the KeyEvent_VK... keycodes where the first dimension is for the 4 playersand the second dimension is for the 6 keys: up, down, left, right, shot, backshot.boolean[][] keyDown is the same for the dimensions and just stores if a key is held down or not.

I played the red baron (http://marcin-kochanowski.com/RedBaron4K.html)which was programmed for the java4k contest in 2009with a friend for hours and it works well with many keys pressed at the sametime. (Up to 9 keys, when 3 people are playing)Unfortunately the programmer didn't release the code, soI couldn't learn from it...If you read this: please help me

As it looks, there seem to be some keyReleased and keyPressed events which aren't processed...Otherwise the boolean values would't remain in their state.

I just read something about the problem with multiple keyspressed at the same time.I have WinXP and my keyboard was connected with the pc by PS2.I read that USB doesn't have this problem (with 3 or more keys pressedalso a noisy beep appears).So I changed the connection from PS2 to USB...I hope it helps, couldn't try so far...

Awesome !!!Your link was really helpful, I understand the actual problem now.Now it should be possible to change my keyboardsettings in order to fit every players movement.I will post it here, when the game works with 2 or maybe 3 players.Maybe anyone else with a similar game can use the layout I choose for the movement.

Thank you a lot

P.S. You may think: "Who in the world is playing a game with two people on one keyboard nowadays?"Actually it is quite fun to play such games in a little tournament with a friend once in a while.Red Baron in J4k is one of our favorite games in the tournament,it is written for one keyboard as well

Open a text entry window of some kind.Press down (and hold down) the 'E' key.Without letting go, press down (and hold down) the 'C' key.Now tap repeatedly on the 'U' key. Do you see any u's coming out on the screen? No? I didn't think so.

Completely unable to reproduce this problem... It's strange

Oh oups, on my keyboard it bug at 7 keys. So no more than 6 key down at a time for me And on my laptop F, G, and H produce a problem but not on my desktop. So I guess that all keyboard are not the same...

Awesome !!!Your link was really helpful, I understand the actual problem now.Now it should be possible to change my keyboardsettings in order to fit every players movement.

You may be able to work around it for your keyboard, but you can be sure other keyboards will behave differently. There are even specialized keyboards that do not have this problem, Google "steelkeys" or "keyboard ghosting". I believe all keyboards will support two keys at once, after that sometimes it will work, sometimes it won't. Of course, the ctrl, alt, and shift modifier keys are separate from this problem.

It's working now.I managed to choose the right keys.That's also possible because a player won't needto press the steer-left-key and the steer-right-key at the same time.On other keyboards it may fail again, butI think most keyboards are the same concerning at least the letters (I don't use 'Z' or 'Y').When the problem appears on another keyboard one canchange the keysettings ingame (This isn't the nicest way but it works).

If anyone wants to know:I chose W,A,S,D for moving the first player and NUM_5,NUM_1,NUM_2,NUM_3 for the second one.F and G are for firing bullets with the first player and for the second one it's NUM_+ and NUM_Enter.I'm trying to find the right keys for the 3rd player now, but the game willmostly be played by just two players.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org