# How do I make a "on button held" function?

**URL:** <https://forum.makecode.com/t/how-do-i-make-a-on-button-held-function/28871>\
**Category:** Arcade\
**Tags:** game\
**Created:** [May 22, 2024, 4:30pm UTC](https://forum.makecode.com/t/how-do-i-make-a-on-button-held-function/28871 "2024-05-22T16:30:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Haybaleson](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/haybaleson/32/15395_2.png) [@Haybaleson](https://forum.makecode.com/u/Haybaleson)\
**Post date:** [May 22, 2024, 4:30pm UTC](https://forum.makecode.com/t/how-do-i-make-a-on-button-held-function/28871/1 "2024-05-22T16:30:34Z")

</div>

I want an on button held function. Something like, when the left button is held and A button is pressed while the Left button is held, it does something like play an animation. I’m trying to make a fighting game similar to Super Smash Bros, and I would like to make an animation play when left or right is pressed and also the A button is pressed.

Thanks.

---

<div class="post-metadata">

**Author:** ![CopySprite](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/copysprite/32/35475_2.png) [@CopySprite](https://forum.makecode.com/u/CopySprite)\
**Post date:** [May 22, 2024, 4:37pm UTC](https://forum.makecode.com/t/how-do-i-make-a-on-button-held-function/28871/2 "2024-05-22T16:37:27Z")

</div>

Welcome @Haybaleson  
First go to extensions.  
 ![Here.](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/a/a3c98a8da33c2b029b1f0b52e595352159832c7a.png)  
Then you should use the button combos extension.  
 ![button-combos](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/f/fe8640442d204a4018c2b66a9ef75e2002b19c52.png)  
This extension can do what you need.

---

<div class="post-metadata">

**Author:** ![Taison](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/taison/32/23189_2.png) [@Taison](https://forum.makecode.com/u/Taison)\
**Post date:** [June 30, 2025, 5:38pm UTC](https://forum.makecode.com/t/how-do-i-make-a-on-button-held-function/28871/3 "2025-06-30T17:38:48Z")

</div>

But how exactly would I do on press and held with this extenstion?

---

<div class="post-metadata">

**Author:** ![Rune](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/rune/32/18951_2.png) [@Rune](https://forum.makecode.com/u/Rune)\
**Post date:** [July 1, 2025, 4:41pm UTC](https://forum.makecode.com/t/how-do-i-make-a-on-button-held-function/28871/4 "2025-07-01T16:41:42Z")

</div>

I don’t think you need that extension. This should do:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/c/6/c6e25791c8c38eac03a7c9c2b18a90e344d67a5f.png)

It’s basically: when you press a, check if left is being pressed.

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [July 1, 2025, 4:54pm UTC](https://forum.makecode.com/t/how-do-i-make-a-on-button-held-function/28871/5 "2025-07-01T16:54:12Z")

</div>

This extension doesn’t really do that. If you want to know if a button has been held for a certain amount of time, you could use a variable like “AHoldTime” that is increased by one in a forever loop if the \<is [A] button pressed\> Boolean is true, and is set to 0 if it’s not.  
Then when the player pressed the other button in the combo, you could check that this variable is above a certain number and activate the ability if it is.

If you just want to check if two buttons are being pressed at the same time, without the timer, you can use two of those \<on button pressed\> booleans to check both buttons at once, or just check the other button when one button is pressed.
