Microsoft MakeCode

How to determine if button A or B is pressed

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.

The hard way: write your own eventhandler

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

1 Like