I'm trying to create a simple application where a rect is drawn on the screen and moved by keys. 'a' is supposed to move the rect down while 's' is supposed to move it upwards. For some reason after I press 'a' and the rect stops at the bottom, 's' takes over and key 'a' becomes unresponsive... Any ideas how the sketch could be improved?
The base logic is flawed. You can have both a and s active at the same time. BTW, the choice of keys is strange, on my keyboard, a is above s... (that's why I don't like the wsad commands, I prefer good old arrow keys). And you have s acting twice in your code.
The logic is still flawed: if I hit s, it goes up. If I then hit a, it stops. Hitting a again, it goes up! See http://wiki.processing.org/w/Multiple_key_presses wiki page for a more suitable even handling: it distinguishes key up and key down events.
Leave a comment on PhiLho's reply
Change topic type
Link this topic
Provide the permalink of a topic that is related to this topic