First of all you cannot declare a loop outside of a method. To fix your problem you should remove the loop and instead change your vely/velx assignments. To register mutiple keys at the same time you should only set one variable to either 1 or -1 and just leave the other one be.
if (code == KeyEvent.VK_DOWN){
vely = 1;
}
now since you are registering multiple keys you also have to differentiate between them in the keyreleased method where you should now set the appropriate velocity to 0 and let the other one stay as it is.