When the key is pressed, you should set some variable by which you determine movement. On KeyReleased you unset this variable.
The way how you handle this it to call the method, for example moveLeft(), and in loop you are checking this variable. On KeyReleased, when you redefine it, the loop ends.