Skip to main content

Keyboard:cursor()

Move the text cursor to a character position in the focused text field.

Signature​

Keyboard:cursor(position: number): void

Parameters​

ParameterTypeDescription
positionnumberCharacter offset from the start of the field; 0 is before the first character

Returns

void

Description​

The position is clamped to the length of the current text. Cursor positioning requires Accessibility mode; in Native (root) mode the call throws because the shell cannot place a cursor reliably.

Example​

Keyboard:type("Hello world")
Keyboard:cursor(5) -- before the space
Keyboard:type(" there") -- "Hello there world"

Compatible Version: 1.0.0.37 and up