2.1.28, initiation update to PXT v5.28.24 (#54)
This commit is contained in:
committed by
Peli de Halleux
parent
38a964516e
commit
5c114a0c57
@@ -6,17 +6,17 @@ Check whether a button is pressed right now. The @boardname@ has two buttons: bu
|
||||
input.buttonIsPressed(Button.A);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* ``button`` is a [String](/reference/types/string). You should store `A` in it to check the left button, `B` to check the right button, or `A+B` to check both at the same time.
|
||||
* ``button`` is a [String](/types/string). You should store `A` in it to check the left button, `B` to check the right button, or `A+B` to check both at the same time.
|
||||
|
||||
### Returns
|
||||
## Returns
|
||||
|
||||
* [Boolean](/blocks/logic/boolean) that is `true` if the button you are checking is pressed, `false` if it is not pressed.
|
||||
* a [boolean](/blocks/logic/boolean) value that is `true` if the button you are checking is pressed, `false` if it is not pressed.
|
||||
|
||||
### Example
|
||||
## Example
|
||||
|
||||
This program uses an [if](/blocks/logic/if) to run
|
||||
This program uses an [``||logic:if||``](/blocks/logic/if) to run
|
||||
one part of the program if the `A` button is pressed, and
|
||||
another part if it is not pressed.
|
||||
|
||||
@@ -25,15 +25,19 @@ basic.forever(() => {
|
||||
let pressed = input.buttonIsPressed(Button.A)
|
||||
if (pressed) {
|
||||
// this part runs if the A button is pressed
|
||||
basic.showNumber(1, 150)
|
||||
basic.showNumber(1)
|
||||
} else {
|
||||
// this part runs if the A button is *not* pressed
|
||||
basic.showNumber(0, 150)
|
||||
basic.showNumber(0)
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### See also
|
||||
Find out how buttons provide input to the @boardname@ in this video:
|
||||
|
||||
https://www.youtube.com/watch?v=t_Qujjd_38o
|
||||
|
||||
## See also
|
||||
|
||||
[on button pressed](/reference/input/on-button-pressed), [if](/blocks/logic/if), [forever](/reference/basic/forever)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user