2016-03-26 00:47:20 +01:00
# button challenges
My script. #docs
### Challenge 0
2016-04-13 17:27:45 +02:00
Howdy! This [guided tutorial ](/rxqgzy ) will help you complete this activity!
2016-03-26 00:47:20 +01: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-30 06:17:57 +02:00
input.onButtonPressed(Button.A, () => {
2016-03-26 00:47:20 +01: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-30 06:17:57 +02:00
input.onButtonPressed(Button.A, () => {
2016-03-26 00:47:20 +01:00
basic.showString("hello", 150)
})
```
### Challenge 1
Let's add an event handler for Button `B` .
```
2016-03-30 06:17:57 +02:00
input.onButtonPressed(Button.A, () => {
2016-03-26 00:47:20 +01:00
basic.showString("hello", 150)
})
2016-03-30 06:17:57 +02:00
input.onButtonPressed(Button.B, () => {
2016-03-26 00:47:20 +01:00
})
```
### Challenge 2
Display `bye` when the `B` button is pressed.
```
2016-03-30 06:17:57 +02:00
input.onButtonPressed(Button.A, () => {
2016-03-26 00:47:20 +01:00
basic.showString("hello", 150)
})
2016-03-30 06:17:57 +02:00
input.onButtonPressed(Button.B, () => {
2016-03-26 00:47:20 +01: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` .