- This article is about the micro:bit Extension block. For the EV3 Extension block, see Button () Pressed? (block).
| () Button Pressed? | |
( v) button pressed? | |
| Category | micro:bit |
| Type | Boolean |
The () Button Pressed? block is a boolean block and a micro:bit block. Its options are "A", "B", and "any". The block returns whether or not the specified button is being pressed on the micro:bit unit.
Example Uses
- Displaying when a specific button is pressed
if <(any v) button pressed?> then
say [Button pressed!]
end
- Movement based on pressing certain buttons
if <(A v) button pressed?> then
move (10) steps
end
if <(B v) button pressed?> then
move (-10) steps
end
- Answering a quiz
say [What is 3 × 2? A: 6 | B: 5]
wait until <(any v) button pressed>
if <(A v) button pressed?> then
say [Correct!]
change [score v] by [10]
end
if <(B v) button pressed> then
say [Incorrect.]
change [lives v] by [-1]
end