# How to determine if button A or B is pressed

**URL:** <https://forum.makecode.com/t/how-to-determine-if-button-a-or-b-is-pressed/11453>\
**Category:** micro:bit\
**Created:** [December 21, 2021, 6:23pm UTC](https://forum.makecode.com/t/how-to-determine-if-button-a-or-b-is-pressed/11453 "2021-12-21T18:23:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![APWhite](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@APWhite](https://forum.makecode.com/u/APWhite)\
**Post date:** [December 21, 2021, 6:23pm UTC](https://forum.makecode.com/t/how-to-determine-if-button-a-or-b-is-pressed/11453/1 "2021-12-21T18:23:47Z")

</div>

This is code that waits for an event coming from button A.

`control.waitForEvent(Button.A, EventBusValue.MICROBIT_EVT_ANY)`

I want to wait for either button A OR button B to be pressed.

Is this possible?

_EDIT_

I know that in `Scratch` this is possible with something like `button.any` , also the above code is written in `microjavascript` , but it is written similarly in `micropython` , so maybe someone from this field can also help. Thank you.

---

<div class="post-metadata">

**Author:** ![MKleinSB](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/mkleinsb/32/593_2.png) [@MKleinSB](https://forum.makecode.com/u/MKleinSB)\
**Post date:** [December 22, 2021, 6:00pm UTC](https://forum.makecode.com/t/how-to-determine-if-button-a-or-b-is-pressed/11453/2 "2021-12-22T18:00:14Z")

</div>

The hard way: write your own eventhandler

The easy way: declare a function and place it in both eventhandlers

 ![grafik](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/b/b02b698b9c9ff67e1ef7fc3383b95c51a9f02b62.png)
