input.onEvent block allows to respond to clicks, double clicks and other classic button events. It can be mounted on button
B or both
A+B together. Internally, MakeCode takes care of handling the pin state, debouncing, timing and other fun stuff.
You can read the live button status using
input.isPressed. In some situations, you might miss clicks because your program was busy while the user was pressing. In such case, you can also use
input.wasPressed which keeps track if the button was pressed between successive calls.