I have code in which when you press the spacebar you jump, yet if you hold the spacebar down the actor just floats upwards
then this i called to move the player
if(Greenfoot.isKeyDown("space")&&!canSee(0,-2)){if(jump==true){Y=-1;jump=false;}else{jump=true;}}else if(canSee(0,2)){Y=0;}else{Y=0.5;}
setLocation(getX()+X,getY()+Y);