# Game Lab and Multiple KeyDown

**URL:** https://forum.code.org/t/game-lab-and-multiple-keydown/34229
**Category:** CS Discoveries
**Tags:** csd-unit-3
**Created:** [February 12, 2021, 4:43pm UTC](https://forum.code.org/t/game-lab-and-multiple-keydown/34229 "2021-02-12T16:43:52Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mcmastersha](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mcmastersha/32/5133_2.png) [@mcmastersha](https://forum.code.org/u/mcmastersha)
#### Post date: [February 12, 2021, 4:43pm UTC](https://forum.code.org/t/game-lab-and-multiple-keydown/34229/1 "2021-02-12T16:43:52Z")

</div>

I have a student who would love to code in different results into a if block. She would like to use space bar to achieve this, for example, is space bar is struck once, something happens, but if there is a double click on the space bar, or a triple click, different things happen. Is there code that will allow this? I’ve search and don’t see an “right there” way to do this. Thoughts?

---

<div class="post-metadata">

### Author: ![melynn](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/melynn/32/4925_2.png) [@melynn](https://forum.code.org/u/melynn)
#### Post date: [February 13, 2021, 2:07pm UTC](https://forum.code.org/t/game-lab-and-multiple-keydown/34229/2 "2021-02-13T14:07:54Z")

</div>

Hi @mcmastersha,

I think the best way to achieve an action on multiple clicks is to add to a variable each time the space bar is clicked and then have the if statement respond to the value of the variable. So, the variable would begin at 0 and with each space bar click, 1 would be added to the variable. If the variable = 1, one action is taken. If the variable = 2, another action is taken. The variable could reset if \> 3 if needed.

Will that work?  
~Michelle

---

<div class="post-metadata">

### Author: ![mriley](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@mriley](https://forum.code.org/u/mriley)
#### Post date: [February 18, 2021, 1:14pm UTC](https://forum.code.org/t/game-lab-and-multiple-keydown/34229/3 "2021-02-18T13:14:34Z")

</div>

There are a few different ways, however, this youtube channel has some excellent tutorials for those advanced students.  
[[Multicolor Shots, Keeping Score, Multiple Targets in Game Lab on Code.org - YouTube](https://www.youtube.com/watch?v=NbWcwTef8w4)]([https://youtube](https://youtube) channel)

---

<div class="post-metadata">

### Author: ![mcmastersha](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mcmastersha/32/5133_2.png) [@mcmastersha](https://forum.code.org/u/mcmastersha)
#### Post date: [February 18, 2021, 1:26pm UTC](https://forum.code.org/t/game-lab-and-multiple-keydown/34229/4 "2021-02-18T13:26:27Z")

</div>

Thank you so much! This is why one of the reasons why I love using this curriculum! Great community work involved here 🙂

---

<div class="post-metadata">

### Author: ![jdonwells](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/jdonwells/32/7900_2.png) [@jdonwells](https://forum.code.org/u/jdonwells)
#### Post date: [February 19, 2021, 4:52pm UTC](https://forum.code.org/t/game-lab-and-multiple-keydown/34229/5 "2021-02-19T16:52:37Z")

</div>

Start with @melynn advice and add a count on the space bar. You need to use the draw() loop to decide how long you wait for multiple clicks.

Like this

> **[Check out what I made](https://studio.code.org/projects/gamelab/nO8yt_XjrB9zQR88Clu8YPNOUdCNmt7l_BMdivEkXBk)**
>
> I wrote the code myself with Code.org
