java - KeyEvents are not received when pressing keys at the same time -


i'm programming game in java has 2 players on same keyboard. if 1 of players holding forward button , second player presses forward button first player stopped. happens other way around , i'm not sure how fix it.

  addkeylistener(new keylistener() {          @override         public void keytyped(keyevent e) {          }         @override         public void keypressed(keyevent e) {             paddle.keypressed(e);             paddletwo.keypressed(e);         }         @override         public void keyreleased(keyevent e) {             paddle.keyreleased(e);             paddletwo.keyreleased(e);         } 

in each paddle class have this:

public void keyreleased (keyevent e) {     ya = 0; }  public void keypressed(keyevent e) {    if(e.getkeycode() == keyevent.vk_up)        ya = -pong.speed;    if(e.getkeycode() == keyevent.vk_down)        ya = pong.speed; } 

player 2 uses vk_w , vk_s instead of , down.

this related actual hardware keyboard. reduce costs control lines shared it's impossible push combination of keys @ same time.

either buy high-end keyboard or choose keys there minimal interference (of course harder more keys use, , result in funny looking controls).

here's reason explained.

edit: shouldn't affect when 2 keys involved, 3 or more.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -