# How to move the image with the arrows

**URL:** <https://discourse.processing.org/t/how-to-move-the-image-with-the-arrows/35536>\
**Category:** Processing\
**Tags:** homework\
**Created:** [March 3, 2022, 11:01am UTC](https://discourse.processing.org/t/how-to-move-the-image-with-the-arrows/35536 "2022-03-03T11:01:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cisky](https://avatars.discourse-cdn.com/v4/letter/c/977dab/32.png) [@cisky](https://discourse.processing.org/u/cisky)\
**Post date:** [March 3, 2022, 11:01am UTC](https://discourse.processing.org/t/how-to-move-the-image-with-the-arrows/35536/1 "2022-03-03T11:01:33Z")

</div>

> please format code with \</\> button \* [homework policy](https://discourse.processing.org/faq/#homework) \* [asking questions](https://discourse.processing.org/t/2147)

i don’t know how i can not leave the last button on read, so let the image doing two movments at the same time. i mean i don’t know how the image can jump and go straight or back either at the same time. i’m using the arrows and not wasd and to jump the space bar.  
if we try to go right and suddendly we need to go left (so we keep the right arrow pressed and we press and release the left arrow) our image would continue on the left side even if we’re still pressing the right arrow. we think it’s because processing keeps reading the last key pressed.

`if (keyPressed){
if (keyCode==RIGHT){
marioX+=3;
}
if (keyCode==LEFT){
marioX-=3;
}
}`

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [March 3, 2022, 12:16pm UTC](https://discourse.processing.org/t/how-to-move-the-image-with-the-arrows/35536/2 "2022-03-03T12:16:52Z")

</div>

see [Players Movement (Java) - OpenProcessing](https://openprocessing.org/sketch/718355)

see [keyPressed and keyReleased with java(eclipse) - #3 by GoToLoop](https://discourse.processing.org/t/keypressed-and-keyreleased-with-java-eclipse/12994/3)

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [March 5, 2022, 10:29am UTC](https://discourse.processing.org/t/how-to-move-the-image-with-the-arrows/35536/3 "2022-03-05T10:29:04Z")

</div>

Hello @cisky,

There is a tutorial here for this:

> **[Processing Tutorials](https://happycoding.io/tutorials/processing/)**
>
> Learn how to program in Processing!

`:)`

---

<div class="post-metadata">

**Author:** ![jackyjoy123](https://avatars.discourse-cdn.com/v4/letter/j/d6d6ee/32.png) [@jackyjoy123](https://discourse.processing.org/u/jackyjoy123)\
**Post date:** [March 5, 2022, 10:57am UTC](https://discourse.processing.org/t/how-to-move-the-image-with-the-arrows/35536/4 "2022-03-05T10:57:38Z")

</div>

> [@cisky](#):
>
> if we try to go right and suddendly we need to go left (so we keep the right arrow pressed and we press and release the left arrow) our image would continue on the left side even if we’re still pressing the right arrow. we think it’s because processing keeps reading the last key pressed.
> 
> `if (keyPressed){ if (keyCode==RIGHT){ marioX+=3; } if (keyCode==LEFT){ marioX-=3; } }`

thanks for the awesome information.
