Not to be confused with When Button () Pressed (block).
When () Button Pressed
when (A v) button pressed
Category micro:bit
Type Hat
Introduced in 3.0

The when () button pressed block is a hat block and a micro:bit block. Its options are "A", "B", and "any". The block activates when the specified button is pressed on the micro:bit unit.

Example Uses

  • Showing an image when a button is pressed:
when (A v) button pressed
display ( v)
  • A sprite moving when a button is pressed.
when (A v) button pressed
move (10) steps