First of all, Is it actually possible for a keyboard to be able to accept input from multiple separate keys at the same time?

For instance, If I was to make a simple game like pong, and set an up and down key for each player, could both players press either up/down at the same time? Or would you have to wait until 1 player wasn't pressing anything?

If not, would trying to set up controls for a gamepad be difficult in java?

AFAIK it's no problem if you handle KEY_PRESSED and KEY_RELEASED KeyEvents.

I meant is it actuall 'physically' possible for the keyboard to record 2 inputs at once. I have another question also:

Lets say I draw an oval on screen, then have it bounce about, why is it that sometimes its speed is cut in half? and then if I run the same thing a couple minutes later, it would be back to normal speed?

Or when it looks like the shape 'speeds' up or 'slows' down randomly. Why does this happen? Is it because of too much logic inside the draw methods thats slowing it down? Or something that happens when you just draw directly on screen without any sort of buffer? I need to know why everything happens lol!

I am not using threads, would this be a cause?(I wouldn't have thought so)

Edited 5 Years Ago by Akill10: n/a

Yes, the keyboard generates events when a key is pressed and when it's released. If you hold down a key while y ou press another you get
key1 pressed
key2 pressed
key2 released
key1 released
(etc)

Without your code I have no idea why things change speed. Are you using a javax.swing.Timer to control your repaints?

Yes, the keyboard generates events when a key is pressed and when it's released. If you hold down a key while y ou press another you get
key1 pressed
key2 pressed
key2 released
key1 released
(etc)

Without your code I have no idea why things change speed. Are you using a javax.swing.Timer to control your repaints?

Yes I'm using Timer. It's only a simple little animation though.

You might think that you are pressing multiple keys at the same time but a few milliseconds between each of themm will make a difference
Anyhow, even if you manage to click 2 keys at exactly the same time, the hardware will sent 2 distinct interrupts and queue (randomly) the 2 key pressed

This question has already been answered. Start a new discussion instead.