Input
Touch gestures, key events, and text input
Every function on this page takes its tuning as an options object:longPress(300, 600, { duration: 1500 }). There is no positional form, and unlike the searches on the Screen Reading page, nothing here tells you when you get it wrong — a bare value in the options position is silently dropped and the call runs with defaults. SolongPress(300, 600, 1500)holds for 500 ms rather than 1500, andfindAndTap("btn", 0.9)matches at the default 0.70 rather than 0.9. If a gesture ignores a value you passed, check that it is wrapped in{ }.
findAndTap(objectName, options?)
Finds an object on screen by image matching and taps its center.
| Parameter | Type | Default | Description |
|---|---|---|---|
objectName | string | — | Name of the UI object defined in the visual editor |
options.threshold | number | 0.70 | Minimum match confidence 0.0–1.0. Higher is stricter. Values below 0.10 are clamped up to 0.10 — a lower threshold would make almost every position on screen a candidate. |
options.matchTimeout | number | — | Maximum milliseconds to spend on the pyramid search. The search stops early after the allotted time; any scales already completed are still used. Omit to accept the engine's own 10-second budget — there is no unlimited setting. |
options.region | Region | — | Overrides the object's own search region from the visual editor. Omitting it does not search the full screen — the editor's region still applies. |
options.randomizeClickRadius | number | — | Sets the jitter radius for this call. Requires click randomization to be enabled in this macro's settings; it does not turn it on. |
options.randomizeDelay | [number, number] | — | Randomized delay before tap (e.g. [50, 150]) |
Returns boolean — true if the object was found and tapped
findAndTap("play_button");
findAndTap("enemy_icon", { threshold: 0.85 }); // stricter match
findAndTap("enemy_icon", { matchTimeout: 200 }); // stop search after 200 ms
findAndTap("enemy_icon", { threshold: 0.85, matchTimeout: 150 });
findAndLongPress(objectName, options?)
Finds an object on screen by image matching and holds a finger at its center.
| Parameter | Type | Default | Description |
|---|---|---|---|
objectName | string | — | Name of the UI object defined in the visual editor |
options.duration | number | 500 | Hold duration in milliseconds. Clamped to 1–60000. |
options.threshold | number | 0.70 | See findAndTap |
options.matchTimeout | number | — | See findAndTap |
options.region | Region | — | See findAndTap |
options.randomizeClickRadius | number | — | See findAndTap |
options.randomizeDelay | [number, number] | — | Randomized delay before long press (e.g. [50, 150]) |
Returns boolean — true if the object was found and the long press was performed
findAndLongPress("item_slot"); // 500 ms hold
findAndLongPress("item_slot", { duration: 1500 }); // 1.5 s hold
findAndLongPress("item_slot", { duration: 1000, threshold: 0.85 });
findAndLongPress("item_slot", { duration: 1000, matchTimeout: 200 }); // cap pyramid search at 200 ms
tapAt(objectName, options?)
tapAt(x, y, options?)
Taps at a known location without performing image matching. Pass an object name to tap its stored center, or pass coordinates to tap at a specific position on screen.
Marketplace macros: raw coordinates (tapAt(x, y),swipe,longPress) are tied to your device's pixel dimensions and will land in the wrong place on other screen sizes. For macros you intend to share, use image-matching functions (findAndTap,findObject(...).tap()) or named objects (tapAt("name")) instead — these are resolution-independent.
| Parameter | Type | Description |
|---|---|---|
objectName | string | Name of the UI object; taps its fixed bounding-box center |
x, y | number | Screen coordinates in current device pixels |
options.randomizeClickRadius | number | Jitter radius for this call — see findAndTap |
options.randomizeDelay | [number, number] | Randomized delay before tap (e.g. [50, 150]) |
Returns boolean — true if the tap was dispatched; false if the named object was not found or the gesture could not be dispatched
tapAt("menu_icon"); // tap stored center of object
tapAt(540, 960); // tap at raw coordinates
swipe(x1, y1, x2, y2, options?)
Performs a swipe gesture from one point to another.
| Parameter | Type | Default | Description |
|---|---|---|---|
x1, y1 | number | — | Start coordinates in current device pixels |
x2, y2 | number | — | End coordinates in current device pixels |
options.duration | number | 300 | Swipe duration in milliseconds. Clamped to 1–60000. |
options.randomizeClickRadius | number | — | Jitter radius — see findAndTap |
options.randomizeDelay | [number, number] | — | Randomized delay before swipe (e.g. [50, 150]) |
Returns boolean — true if the swipe was dispatched; false if the accessibility service is inactive or the gesture was cancelled by the system
swipe(100, 500, 100, 200); // default duration
swipe(100, 500, 100, 200, { duration: 400 }); // custom duration
longPress(objectName, options?)
longPress(x, y, options?)
Holds a finger at a known location without performing image matching. Pass an object name to long-press its stored center (mirroring tapAt(objectName)), or pass coordinates to press a specific position on screen.
| Parameter | Type | Default | Description |
|---|---|---|---|
objectName | string | — | Name of the UI object; presses its fixed bounding-box center |
x, y | number | — | Coordinates to press in current device pixels |
options.duration | number | 500 | Hold duration in milliseconds. Clamped to 1–60000. |
options.randomizeClickRadius | number | — | Jitter radius — see findAndTap |
options.randomizeDelay | [number, number] | — | Randomized delay before long press (e.g. [50, 150]) |
Returns boolean — true if the long press was dispatched; false if the named object was not found, the accessibility service is inactive, or the gesture was cancelled by the system
longPress("menu_icon"); // hold stored center of object
longPress(300, 600); // default duration
longPress(300, 600, { duration: 1000 }); // custom duration
multiLongPress(positions, options?)
Holds multiple fingers at the given coordinates simultaneously. Each finger can have its own hold duration by passing a third element in its coordinate tuple; fingers without an individual duration fall back to options.duration. The call blocks until the longest-held finger is released, so it takes at least the largest duration among the positions.
| Parameter | Type | Default | Description |
|---|---|---|---|
positions | Array<[x, y, duration?]> | — | Array of [x, y] or [x, y, duration] tuples |
options.duration | number | 500 | Fallback hold duration in ms for fingers that do not specify their own. Clamped to 1–60000. |
options.randomizeClickRadius | number | — | Jitter radius (px) applied to each finger's position. Requires click randomization to be enabled. |
options.randomizeDelay | [number, number] | — | Randomized delay before the gesture (e.g. [50, 150]) |
Returns boolean — true if the gesture was dispatched (false if no valid positions were supplied or it was cancelled); blocks until the longest finger is released
// All fingers held for the same duration
multiLongPress([[100, 200], [300, 400]], { duration: 1000 });
// Each finger with its own duration (no options needed)
multiLongPress([[500, 200, 3000], [500, 400, 7000], [500, 600, 10000]]);
// Mixed — third finger falls back to options.duration
multiLongPress([[500, 200, 3000], [500, 400]], { duration: 5000 });
Why not three separatespawnThread+longPresscalls? Android's AccessibilityService only allows one active gesture at a time. Dispatching a second gesture cancels the first, so three concurrentlongPresscalls will cancel each other in a rapid loop, causing visible flickering.multiLongPresspacks all fingers into a single gesture dispatch, which is the only reliable way to hold multiple touch points simultaneously.
multiSwipe(fingers, options?)
Performs multiple synchronized swipe gestures simultaneously. All fingers begin and end their swipes at the same time.
| Parameter | Type | Default | Description |
|---|---|---|---|
fingers | Array<[x1, y1, x2, y2]> | — | Array of swipe coordinate tuples |
options.duration | number | 300 | Duration of the entire multi-swipe gesture in ms. Clamped to 1–60000. |
options.randomizeClickRadius | number | — | Shared jitter radius applied to all fingers — see findAndTap |
options.randomizeDelay | [number, number] | — | Randomized delay before the gesture (e.g. [50, 150]) |
Returns boolean — true if the gesture was dispatched; false if no valid fingers were supplied or it was cancelled
// Swipe with two fingers simultaneously
multiSwipe([[100, 500, 100, 200], [300, 500, 300, 200]], { duration: 400 });
Note: when click randomization is enabled, one shared jitter offset is applied to every finger so the inter-finger geometry (e.g. a two-finger pan) is preserved — the fingers are not jittered independently.
performGesture(nameOrId)
Executes a complex, pre-recorded gesture sequence defined in the visual editor.
| Parameter | Type | Description |
|---|---|---|
nameOrId | string | Name or ID of the recorded gesture — the lookup tries the name first, then the ID. |
Returns boolean — true if the gesture was found and dispatched
performGesture("complex_unlock_pattern");
pinch(cx, cy, amount, options?)
Performs a zoom or pinch gesture around a center point.
| Parameter | Type | Default | Description |
|---|---|---|---|
cx, cy | number | — | Center of the gesture in current device pixels |
amount | number | — | Positive = zoom in, negative = zoom out (pixel span delta) |
options.duration | number | 300 | Gesture duration in milliseconds. Floored at 50 and clamped to 1–60000, so the effective range is 50–60000. |
options.randomizeClickRadius | number | — | Jitter radius for the center — see findAndTap |
options.randomizeDelay | [number, number] | — | Randomized delay before the gesture (e.g. [50, 150]) |
Returns boolean — true if the gesture was dispatched; false if the accessibility service is inactive or the gesture was cancelled by the system
pinch(540, 960, 200); // zoom in, default duration
pinch(540, 960, -200, { duration: 400 }); // zoom out, custom duration
Note: when click randomization is enabled, the center is jittered (userandomizeClickRadiusto set the radius) and the finger span and duration are varied slightly so repeated pinches aren't identical. With randomization off, the gesture centers on the exactcx, cywith thedurationyou pass — still floored at 50 ms, so a smaller value is raised to 50.
keyEvent(keyCode)
Sends an Android key event. Use the built-in KeyCode object for readable named constants instead of raw numbers.
| Parameter | Type | Description |
|---|---|---|
keyCode | number | Android KeyEvent constant. See the KeyCode reference below. |
Returns boolean — true if the key event was dispatched; false if the keycode isn't supported on the current input backend. Without Shizuku only HOME, BACK and APP_SWITCH are deliverable — they map to system global actions; every other keycode needs Shizuku
keyEvent(KeyCode.BACK); // press Back
keyEvent(KeyCode.HOME); // press Home
keyEvent(KeyCode.ENTER); // confirm input
KeyCode
A frozen object of named Android key code constants. Prevents typos and makes scripts self-documenting.
| Constant | Value | Description |
|---|---|---|
KeyCode.HOME | 3 | Home button |
KeyCode.BACK | 4 | Back button |
KeyCode.DPAD_UP | 19 | D-pad up |
KeyCode.DPAD_DOWN | 20 | D-pad down |
KeyCode.DPAD_LEFT | 21 | D-pad left |
KeyCode.DPAD_RIGHT | 22 | D-pad right |
KeyCode.DPAD_CENTER | 23 | D-pad center / confirm |
KeyCode.VOLUME_UP | 24 | Volume up |
KeyCode.VOLUME_DOWN | 25 | Volume down |
KeyCode.POWER | 26 | Power button |
KeyCode.TAB | 61 | Tab key |
KeyCode.SPACE | 62 | Space key |
KeyCode.ENTER | 66 | Enter / confirm |
KeyCode.DEL | 67 | Backspace |
KeyCode.ESCAPE | 111 | Escape key |
KeyCode.FORWARD_DEL | 112 | Delete (forward) |
KeyCode.APP_SWITCH | 187 | Recents / app switcher |
inputText(text)
Types text into the currently focused field. This replaces the field's existing content (via the accessibility set-text action, with a clipboard-paste fallback); it does not append or insert at the cursor.
| Parameter | Type | Description |
|---|---|---|
text | string | Text to type |
Returns boolean — true if the text was dispatched; false if no input field is focused
inputText("Hello world");