2016-03-25 16:47:20 -07:00
# button challenges
My script. #docs
### Challenge 0
2016-04-13 08:27:45 -07:00
Howdy! This [guided tutorial ](/rxqgzy ) will help you complete this activity!
2016-03-25 16:47:20 -07:00
In this guide, you will learn how to use buttons and show text on the screen. Let's start by adding to respond **when the left button is pressed** .
```
2016-03-29 21:17:57 -07:00
input.onButtonPressed(Button.A, () => {
2016-03-25 16:47:20 -07:00
})
```
All the code inside `input->on button pressed` runs when the button is pressed. Let's add the code to show some text.
```
2016-03-29 21:17:57 -07:00
input.onButtonPressed(Button.A, () => {
2016-03-25 16:47:20 -07:00
basic.showString("hello", 150)
})
```
### Challenge 1
Let's add an event handler for Button `B` .
```
2016-03-29 21:17:57 -07:00
input.onButtonPressed(Button.A, () => {
2016-03-25 16:47:20 -07:00
basic.showString("hello", 150)
})
2016-03-29 21:17:57 -07:00
input.onButtonPressed(Button.B, () => {
2016-03-25 16:47:20 -07:00
})
```
### Challenge 2
Display `bye` when the `B` button is pressed.
```
2016-03-29 21:17:57 -07:00
input.onButtonPressed(Button.A, () => {
2016-03-25 16:47:20 -07:00
basic.showString("hello", 150)
})
2016-03-29 21:17:57 -07:00
input.onButtonPressed(Button.B, () => {
2016-03-25 16:47:20 -07:00
basic.showString("bye", 150)
})
```
### Challenge 3
Change the strings so that they display some other text. In order to do so, you will need to edit what is inside the quotation marks in `basic->show string` .