Hi, I'm creating a version of Pong in java, but I have a problem. When I hold down the buttons to move the left and right paddles at the same time, only the one that I hit most recently is registered. I was wondering how I could get them to work simultaneously. Thanks for the help.

Here is my code if it helps:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.AudioClip;
import java.net.URL;

public class PongPanel extends JPanel
{
private final int WIDTH = 600, HEIGHT = 400;
private final int DELAY = 20, IMAGE_SIZE = 30;
private final int MOVE = 5;
private final int REC_WIDTH = 10, REC_HEIGHT = 50;
private int LRecX = 10, RRecX = 580;
private int LRecY = 180, RRecY = 180;
private Timer timer;
private ImageIcon image;
private int scoreL = 0, scoreR = 0;
private int x, y;
private double moveX = 3, moveY = 3;

public PongPanel()
{
addKeyListener (new DirectionListener());

timer = new Timer(DELAY, new ReboundListener());

image = new ImageIcon ("Smiley.gif");

x = 50;
y = 50;

setPreferredSize (new Dimension(WIDTH, HEIGHT));
setBackground (Color.black);

timer.start();

setFocusable(true);
}

public void paintComponent(Graphics page)
{
super.paintComponent(page);
image.paintIcon (this, page, x, y);

page.setColor (Color.white);
page.fillRect (LRecX, LRecY, REC_WIDTH, REC_HEIGHT); // paints paddles
page.fillRect (RRecX, RRecY, REC_WIDTH, REC_HEIGHT);

page.drawString("" + scoreL, 288, 10);
page.drawString("" + scoreR, 310, 10);
}

private class ReboundListener implements ActionListener
{
public void actionPerformed (ActionEvent event)
{
x += moveX; // moves ball
y += moveY;

Rectangle rectL = new Rectangle(LRecX, LRecY, REC_WIDTH, REC_HEIGHT);
Rectangle rectR = new Rectangle(RRecX, RRecY, REC_WIDTH, REC_HEIGHT);
Rectangle imageRect = new Rectangle(x, y, IMAGE_SIZE, IMAGE_SIZE);

if(rectL.intersects(imageRect)) // reverses direction of ball if it hits left paddle
{
if (moveX < 0)
moveX -= .3;
else
moveX += .3;

if (moveY < 0)
moveY -= .3;
else
moveY += .3;

moveX = moveX * -1;
}

if(rectR.intersects(imageRect)) // reverses direction of ball if it hits right paddle
{
if (moveX < 0)
moveX -= .3;
else
moveX += .3;

if (moveY < 0)
moveY -= .3;
else
moveY += .3;

moveX = moveX * -1;
}

if (y <= 0 || y >= HEIGHT-IMAGE_SIZE) // bounces of top and bottom of screen
{
moveY = moveY * -1;
}

if (x < 0) // starts over if right scores
{
scoreR += 1;

x = 50;
y = 50;

moveX = 4;
moveY = 4;
}

if (x > WIDTH-IMAGE_SIZE) // starts over if left scores
{
scoreL += 1;

x = 50;
y = 50;

moveX = 4;
moveY = 4;
}

repaint();
}
}

private class DirectionListener implements KeyListener
{
public void keyPressed (KeyEvent event)
{
switch (event.getKeyCode()) // moves paddles
{
case KeyEvent.VK_UP:
RRecY -= MOVE; // up and down for right paddle
break;
case KeyEvent.VK_DOWN:
RRecY += MOVE;
break;
case KeyEvent.VK_A:
LRecY -= MOVE; // a and z for left paddle
break;
case KeyEvent.VK_Z:
LRecY += MOVE;
break;
}

repaint();
}

public void keyTyped (KeyEvent event) {}
public void keyReleased (KeyEvent event) {}
}
}