pxt-calliope/docs/reference/input/on-gesture.md
Guillaume Jenkins 7f4cf50ee0
Make randomRange more consistent in docs (#1032)
* Make randomRange more consistent in docs

* Change formulation
2018-08-02 14:49:16 -04:00

27 lines
680 B
Markdown

# On Gesture
Start an [event handler](/reference/event-handler) (part of the
program that will run when something happens) This handler works when
you do a **gesture** (like shaking the @boardname@).
```sig
input.onGesture(Gesture.Shake,() => {
})
```
## Parameters
* ``gesture`` means the way you hold or move the @boardname@. This can be `shake`, `logo up`, `logo down`, `screen up`, `screen down`, `tilt left`, `tilt right`, `free fall`, `3g`, or `6g`.
## Example: random number
This program shows a number from `2` to `9` when you shake the @boardname@.
```blocks
input.onGesture(Gesture.Shake,() => {
let x = Math.randomRange(2, 9)
basic.showNumber(x)
})
```