Continuous movement with a single key press?
I'm trying to make a program in java that involves making an object move constantly from a single key press. Think Pacman, where you press up once and Pacman continues to go up until you press another key. I want to keep the code simple if possible. My original movement (one keypress = one movement) is like this: public class AL extends KeyAdapter { public void keyPressed(KeyEvent e){ int keyCode = e.getKeyCode(); if(keyCode == e.VK_A){ x -= 5; } if(keyCode == e.VK_D){ x += 5; } if(keyCode == e.VK_W){ y -= 5; } if(keyCode == e.VK_S){ y += 5; } } The x and y in values are the position of an