Moving objects using mouse pressed and key pressed

Hi, I want to move a square down by 3 pixels using mouse pressed and and 3 pixels up by using key pressed. How would I do this? I’ve already coded the square in the middle of the 100 x 100 canvas.

1 Like

Store the position in a x variable

Then look at functions mousePressed () and keyPressed ()

MUST be with the ()



1 Like