User Input > Mobile-Only


Note: These blocks only work on iOS and Android. They have no effect on other platforms (or return 0/-1/useless values).


Accelerometer

Accelerometer Value

accel-block

Returns the current values for the accelerometer.

Portrait Orientation

Name Description
X (Positive) Right
X (Negative) Left
Y (Positive) Up
Y (Negative) Down

Landscape Orientation

Name Description
X (Positive) Up
X (Negative) Down
Y (Positive) Left
Y (Negative) Right
Input.accelX
Input.accelY

Gestures

Swiped

swipe-block

Returns true if the user has swiped [up/down/left/right]. A swipe is defined as touching the screen, sliding the finger and then releasing.

Input.swipedUp
Input.swipedDown
Input.swipedLeft
Input.swipedRight

Alernate Approach: Events

swipe-event

We recommend using a swipe event instead of a swipe block. It's easier to work with.


Other

Show / Hide Keyboard

keyboard-block

Immediately shows or hides the virtual keyboard. Use mobile keyboard events to track what's been typed.

example

showKeyboard();
hideKeyboard();

Set Keyboard Text

text-block

Imagine that the keyboard is inputting into an invisible text field. This sets the text that's in that text field.

setKeyboardText([TEXT]);

Clear Keyboard Text

clear-block

Imagine that the keyboard is inputting into an invisible text field. This clears out the text that's in that text field.

setKeyboardText("");

Vibrate

vibrate-block

Vibrates the device for the given number of seconds. On some devices, vibration duration cannot be controlled.

vibrate([NUMBER]);