Explain what pressed events do (#469)
This commit is contained in:
parent
1ac227fb7f
commit
39071b5626
@ -5,6 +5,9 @@ This handler works when button `A` or `B` is pressed, or `A` and `B` together.
|
|||||||
When you are using this function in a web browser, click the buttons on the screen instead of the ones
|
When you are using this function in a web browser, click the buttons on the screen instead of the ones
|
||||||
on the @boardname@.
|
on the @boardname@.
|
||||||
|
|
||||||
|
* For button `A` or `B`: This handler works when the button is pushed down and released within 1 second.
|
||||||
|
* For `A` and `B` together: This handler works when `A` and `B` are both pushed down, then one of them is released within 1.5 seconds of pushing down the second button.
|
||||||
|
|
||||||
```sig
|
```sig
|
||||||
input.onButtonPressed(Button.A, () => {})
|
input.onButtonPressed(Button.A, () => {})
|
||||||
```
|
```
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
Start an [event handler](/reference/event-handler) (part of the
|
Start an [event handler](/reference/event-handler) (part of the
|
||||||
program that will run when something happens, like when a button is
|
program that will run when something happens, like when a button is
|
||||||
pressed). This handler works when you press pin `0`, `1`, or `2`
|
pressed). This handler works when you touch pin `0`, `1`, or `2`
|
||||||
together with `GND`. When you are using this function in a web
|
together with `GND`, and release it within 1 second.
|
||||||
|
When you are using this function in a web
|
||||||
browser, click the pins on the screen instead of the ones on the
|
browser, click the pins on the screen instead of the ones on the
|
||||||
@boardname@.
|
@boardname@.
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@
|
|||||||
"input.lightLevel": "Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.",
|
"input.lightLevel": "Reads the light level applied to the LED screen in a range from ``0`` (dark) to ``255`` bright.",
|
||||||
"input.magneticForce": "Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.",
|
"input.magneticForce": "Get the magnetic force value in ``micro-Teslas`` (``µT``). This function is not supported in the simulator.",
|
||||||
"input.magneticForce|param|dimension": "TODO",
|
"input.magneticForce|param|dimension": "TODO",
|
||||||
"input.onButtonPressed": "Do something when a button (``A``, ``B`` or both ``A+B``) is pressed",
|
"input.onButtonPressed": "Do something when a button (A, B or both A+B) is pushed down and released again.",
|
||||||
"input.onButtonPressed|param|body": "code to run when event is raised",
|
"input.onButtonPressed|param|body": "code to run when event is raised",
|
||||||
"input.onButtonPressed|param|button": "the button that needs to be pressed",
|
"input.onButtonPressed|param|button": "the button that needs to be pressed",
|
||||||
"input.onGesture": "Do something when when a gesture is done (like shaking the micro:bit).",
|
"input.onGesture": "Do something when when a gesture is done (like shaking the micro:bit).",
|
||||||
@ -120,7 +120,7 @@
|
|||||||
"input.onLogoDown|param|body": "TODO",
|
"input.onLogoDown|param|body": "TODO",
|
||||||
"input.onLogoUp": "Attaches code to run when the logo is oriented upwards and the board is vertical.",
|
"input.onLogoUp": "Attaches code to run when the logo is oriented upwards and the board is vertical.",
|
||||||
"input.onLogoUp|param|body": "TODO",
|
"input.onLogoUp|param|body": "TODO",
|
||||||
"input.onPinPressed": "Do something when a pin is pressed.",
|
"input.onPinPressed": "Do something when a pin is touched and released again (while also touching the GND pin).",
|
||||||
"input.onPinPressed|param|body": "the code to run when the pin is pressed",
|
"input.onPinPressed|param|body": "the code to run when the pin is pressed",
|
||||||
"input.onPinPressed|param|name": "the pin that needs to be pressed, eg: TouchPin.P0",
|
"input.onPinPressed|param|name": "the pin that needs to be pressed, eg: TouchPin.P0",
|
||||||
"input.onPinReleased": "Do something when a pin is released.",
|
"input.onPinReleased": "Do something when a pin is released.",
|
||||||
|
@ -150,7 +150,7 @@ enum class MesDpadButtonInfo {
|
|||||||
//% color=#B4009E weight=99 icon="\uf192"
|
//% color=#B4009E weight=99 icon="\uf192"
|
||||||
namespace input {
|
namespace input {
|
||||||
/**
|
/**
|
||||||
* Do something when a button (``A``, ``B`` or both ``A+B``) is pressed
|
* Do something when a button (A, B or both A+B) is pushed down and released again.
|
||||||
* @param button the button that needs to be pressed
|
* @param button the button that needs to be pressed
|
||||||
* @param body code to run when event is raised
|
* @param body code to run when event is raised
|
||||||
*/
|
*/
|
||||||
@ -180,7 +180,7 @@ namespace input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do something when a pin is pressed.
|
* Do something when a pin is touched and released again (while also touching the GND pin).
|
||||||
* @param name the pin that needs to be pressed, eg: TouchPin.P0
|
* @param name the pin that needs to be pressed, eg: TouchPin.P0
|
||||||
* @param body the code to run when the pin is pressed
|
* @param body the code to run when the pin is pressed
|
||||||
*/
|
*/
|
||||||
|
4
libs/core/shims.d.ts
vendored
4
libs/core/shims.d.ts
vendored
@ -216,7 +216,7 @@ declare namespace basic {
|
|||||||
declare namespace input {
|
declare namespace input {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do something when a button (``A``, ``B`` or both ``A+B``) is pressed
|
* Do something when a button (A, B or both A+B) is pushed down and released again.
|
||||||
* @param button the button that needs to be pressed
|
* @param button the button that needs to be pressed
|
||||||
* @param body code to run when event is raised
|
* @param body code to run when event is raised
|
||||||
*/
|
*/
|
||||||
@ -237,7 +237,7 @@ declare namespace input {
|
|||||||
function onGesture(gesture: Gesture, body: () => void): void;
|
function onGesture(gesture: Gesture, body: () => void): void;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do something when a pin is pressed.
|
* Do something when a pin is touched and released again (while also touching the GND pin).
|
||||||
* @param name the pin that needs to be pressed, eg: TouchPin.P0
|
* @param name the pin that needs to be pressed, eg: TouchPin.P0
|
||||||
* @param body the code to run when the pin is pressed
|
* @param body the code to run when the pin is pressed
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user