# Odd Button Pressed behavior?

**URL:** <https://forum.makecode.com/t/odd-button-pressed-behavior/27873>\
**Category:** Show & Tell\
**Created:** [March 21, 2024, 4:37pm UTC](https://forum.makecode.com/t/odd-button-pressed-behavior/27873 "2024-03-21T16:37:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Don23805](https://avatars.discourse-cdn.com/v4/letter/d/b3f665/32.png) [@Don23805](https://forum.makecode.com/u/Don23805)\
**Post date:** [March 21, 2024, 4:37pm UTC](https://forum.makecode.com/t/odd-button-pressed-behavior/27873/1 "2024-03-21T16:37:24Z")

</div>

Simple code: in an On Button A Pressed box I include Show Icon X, Pause two seconds then Show Icon O, and wait for another press. If I press A and release it right away (within about 1 second) all works as expected. But if I wait more than about a second before releasing A it ignores the action. Bug? Documented?  
TIA Don

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [March 21, 2024, 4:37pm UTC](https://forum.makecode.com/t/odd-button-pressed-behavior/27873/2 "2024-03-21T16:37:46Z")

</div>

@Don23805 please share a link to your code!

---

<div class="post-metadata">

**Author:** ![Don23805](https://avatars.discourse-cdn.com/v4/letter/d/b3f665/32.png) [@Don23805](https://forum.makecode.com/u/Don23805)\
**Post date:** [March 21, 2024, 9:28pm UTC](https://forum.makecode.com/t/odd-button-pressed-behavior/27873/3 "2024-03-21T21:28:24Z")

</div>

Not sure if this will work, but here goes

> **[junk](https://makecode.microbit.org/53105-58641-55598-48970)**
>
> Made with ❤️ in Microsoft MakeCode for micro:bit.

It DOES work !  
Actually very simple

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [March 21, 2024, 9:42pm UTC](https://forum.makecode.com/t/odd-button-pressed-behavior/27873/4 "2024-03-21T21:42:56Z")

</div>

The micro:bit actually fires a “long pressed” event when you hold down the button for more than 1 second. The “on button pressed” block only waits for the short click event. We don’t actually surface any blocks to use the long pressed event, but if you happen to know the event id value (which is 4) you can subscribe to it using the generic event block from the control category:

> **[long-button-press](https://makecode.microbit.org/51278-55306-58363-10971)**
>
> Made with ❤️ in Microsoft MakeCode for micro:bit.

---

<div class="post-metadata">

**Author:** ![bsiever](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/bsiever/32/1032_2.png) [@bsiever](https://forum.makecode.com/u/bsiever)\
**Post date:** [April 21, 2024, 11:25pm UTC](https://forum.makecode.com/t/odd-button-pressed-behavior/27873/5 "2024-04-21T23:25:27Z")

</div>

@Don23805 The Button Clicks extension provides a few more options with buttons, like the ability to detect when a button is just pressed down (not a press/release combo that the default “`on pressed`” detects). It also provides detection of single clicks vs. double clicks and press/holds.

Here’s a variation of your example using the extension’s `on button down`: [https://makecode.microbit.org/S25570-81546-11007-69922](https://makecode.microbit.org/S25570-81546-11007-69922) . It will miss additional “button down” events if it’s not yet done handling previous ones, so it won’t respond to additional clicks down in the ~2.1s interval it’s dealing with prior clicks.

If you want to catch all button presses, it’s possible to _count_ clicks. and use a `forever` loop to handle them: [https://makecode.microbit.org/S04105-41320-76538-12318](https://makecode.microbit.org/S04105-41320-76538-12318) .
