Input

Input

An input to send to an instance.

Inputs consist of a series of steps. Each method in this class adds a step to the current input, and returns the current input to allow chaining. To run the input, send it to an instance with Instance#sendInput.

A global, I, is provided as a convenience. I.doThing() is a shorthand for new Input().doThing().

Constructor

new Input()

Description:
  • Creates a new input with no steps. It's usually more convenient to use I instead.

Source:
See:
Example
const input = new Input().pressRelease('home').tap(100, 100);
await instance.sendInput(input);
// using the I shortcut
const input2 = I.pressRelease('home').tap(100, 100);
await instance.sendInput(input2);

Methods

delay(delayopt)

Description:
  • Add a step to delay by the specified number of milliseconds.

Source:
Parameters:
Name Type Attributes Default Description
delay number <optional>
100

The number of milliseconds to delay.

Returns:

this

press(…buttonNames)

Description:
  • Add a step to press and hold the specified buttons.

Source:
Parameters:
Name Type Attributes Description
buttonNames Input~ButtonName <repeatable>

Names of buttons to press.

Returns:

this

pressRelease(button, delayopt)

Description:
  • Add steps to press the specified button, delay for an interval defaulting to 100 milliseconds, and release the specified button.

Source:
Parameters:
Name Type Attributes Default Description
button Input~ButtonName

The button to press and release.

delay number <optional>
100

The number of milliseconds to hold down the button.

Returns:

this

release(…buttonNames)

Description:
  • Add a step to release the specified buttons.

Source:
Parameters:
Name Type Attributes Description
buttonNames Input~ButtonName <repeatable>

Names of buttons to release.

Returns:

this

swipeTo(x, y, curveopt)

Description:
  • Add a step to swipe from the current touch position to the specified position. Bezier control points may be specified. If there is a delay step immediately before this one, the swipe will take place over the delay; otherwise it will happen instantly.

Source:
Parameters:
Name Type Attributes Description
x number

The x coordinate to swipe to.

y number

The y coordinate to swipe to.

curve Array.<point> <optional>

An array of Bezier control points. Each point is a two-element array containing an x coordinate and a y coordinate.

tap(x, y, delayopt)

Description:
  • Add steps to touch the screen at the given position, delay for an interval defaulting to 100 milliseconds, and release the touchscreen.

Source:
Parameters:
Name Type Attributes Default Description
x number

The x coordinate.

y number

The y coordinate.

delay number <optional>
100

The number of milliseconds to hold down the touch.

touch(x, y)

Description:
  • Add a step to set the current touch position and start touching the screen.

Source:
Parameters:
Name Type Description
x number

The x coordinate.

y number

The y coordinate.

Returns:

this

touchUp()

Description:
  • Add a step to release the touchscreen.

Source:
Returns:

this

Type Definitions

ButtonName

Description:
  • The name of a button. Possible values are:

    Button Description
    'home' Home button
    'power' Power button
    'volume-up' Volume up button
    'volume-down' Volume down button
    'ringer' Ringer switch
Source:

The name of a button. Possible values are:

Button Description
'home' Home button
'power' Power button
'volume-up' Volume up button
'volume-down' Volume down button
'ringer' Ringer switch
Type:
  • string