# Mouse/key pressed question

**URL:** <https://discourse.processing.org/t/mouse-key-pressed-question/27417>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [January 27, 2021, 6:42pm UTC](https://discourse.processing.org/t/mouse-key-pressed-question/27417 "2021-01-27T18:42:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![QueensGambit](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/queensgambit/32/11921_2.png) [@QueensGambit](https://discourse.processing.org/u/QueensGambit)\
**Post date:** [January 27, 2021, 6:42pm UTC](https://discourse.processing.org/t/mouse-key-pressed-question/27417/1 "2021-01-27T18:42:56Z")

</div>

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

Hi!!  
I need some help with a project. I need to put in images and when I push for example number 1 a certain image pops up and when I push number 2 another image shows up. I just don’t know how to do it.

https://editor.p5js.org/lieve.otter/embed/Z1YxIcz40

---

<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:** [January 27, 2021, 6:48pm UTC](https://discourse.processing.org/t/mouse-key-pressed-question/27417/2 "2021-01-27T18:48:39Z")

</div>

in the keyPressed() function set a variable showWhichImage  
to 1 or 2, depending on your input

And then:

before setup()

`int showWhichImage=1;`

in draw() :

```auto
if(showWhichImage==1)
    image(a1,....
else if (showWhichImage==1)
    image(b1,....

```

Hey, and welcome to the forum!

Great to have you here!

Warm regards,

Chrisir
