Skip to main content

Input Text (key.input_text)

This function is available in versions after 20260816

Declaration​

success, error = key.input_text(text [, press_enter_when_done ])

Parameters​

  • text
    String. The UTF-8 text to input. It may be empty. Each "\b" performs a Backspace action.
  • press_enter_when_done
    Boolean. Whether to press Enter after entering the text. Default: false.

Return Values​

  • success
    Boolean. Returns true when the simulated input operation is sent, or false on failure.
  • error
    String. The error reason when the operation fails.

Description​

Enters text into the focused field of the foreground app by simulating the way an input method commits selected text.

This function does not read or modify the shared system pasteboard.

This function cannot enter text into password fields. Use sys.input_text for password fields.

A true return value only means that the simulated input operation was sent; it does not guarantee that the target field accepted the text.

Examples​

local ok, err = key.input_text("Hello, XXTouch 🙂")
assert(ok, err)
--
local ok, err = key.input_text("hello!\b", true)
assert(ok, err)