Hello! I am writing a program where i am trying to control a rectangle and determine where it moves, everything is working fine it is moving but i am trying to figure out how to change direction using the "WASD" keys. This is what I have and I am not sure why its not working. Any tips ?

You're setting both your horizontal and vertical speed when any key is pressed. That doesn't seem right. You probably only want to set the horizontal speed when A or D are pressed (and released), and you probably only want to set the vertical speed when the W or S are pressed (and released).

03-11-2014, 06:11 PM

rang3tastic

Re: Key Presses

Although it may not seem right, it is working as expected. I have used the same code for mouse listener, and it is working with mouse clicks. My issue here is not whether the speed or not is set correctly, my issue is that it is unresponsive to my key presses.

03-11-2014, 06:20 PM

KevinWorkman

Re: Key Presses

Can you create an SSCCE that demonstrates exactly the problem? Does you keyReleased() function get triggered at all?