Hello. I want to be able to move the object by rapidly pressing alternate keys. However, whenever I hold down a button, the object keeps moving, which is not what I want. This is my code for moving.
public void movement()
{
int x = getX();
int y = getY();
int r = 2;
//
String key = Greenfoot.getKey();
if (key == null) return;
if ("s".equals(key)){
x+=2;
}
if ("a".equals(key))
{
x+=2;
}
setLocation(x,y);
}

