AXedocs
Install

Keyboard & Text Input

Type text, press HID key codes, run key sequences and send modifier shortcuts, on simulators and physical devices.

AXe sends keyboard input as HID key codes for the US keyboard layout. That is deterministic, and it means type can only send characters on a US keyboard.

Type text#

type takes exactly one source: the text as an argument, --stdin or --file.

shell
axe type 'Hello, world!' --udid "$UDID"
printf 'line one\nline two' | axe type --stdin --udid "$UDID"
axe type --file message.txt --udid "$UDID"

Focus the field first, for example with tap --id EmailField. type does not clear existing text. A character outside the US layout, such as é or £, fails with invalidArguments before anything is typed.

On a physical device, and in agent and selected modes, one type command sends at most 256 UTF-8 bytes.

Text outside the US layout

To enter accented or non-Latin text in a simulator, put it on the clipboard with axe clipboard copy --stdin, then paste it in the app. See Command Reference.

Single keys#

shell
axe key 40 --udid "$UDID"                 # Return
axe key 42 --duration 1.0 --udid "$UDID"  # hold Backspace for one second

The key code is 0 to 255. --duration holds the key for up to 10 seconds.

Key sequences#

shell
axe key-sequence --keycodes 11,8,15,15,18 --udid "$UDID"         # h e l l o
axe key-sequence --keycodes 42,42 --delay 0.2 --udid "$UDID"     # two Backspaces

--keycodes is a comma-separated list of up to 100 codes. --delay between keys defaults to 0.1 seconds (0 to 5).

Shortcuts#

key-combo holds the modifiers in order, presses one key, then releases the modifiers in reverse order.

shell
axe key-combo --modifiers 227 --key 4 --udid "$UDID"       # Cmd+A
axe key-combo --modifiers 227 --key 6 --udid "$UDID"       # Cmd+C
axe key-combo --modifiers 227 --key 25 --udid "$UDID"      # Cmd+V
axe key-combo --modifiers 227,225 --key 29 --udid "$UDID"  # Cmd+Shift+Z

A combo holds 1 to 8 modifiers.

In agent mode#

Agents type into a field by ref. --focus taps the field, waits for focus and types in one call:

shell
axe type 'London' --agent --focus --snapshot-id "$SNAPSHOT_ID" --ref e7 --udid "$UDID"
axe key 42 --agent --snapshot-id "$SNAPSHOT_ID" --ref e7 --udid "$UDID"

AXe checks before every key that the same field still has focus. See Agent Mode.

Common key codes#

KeyCodeKeyCode
a4Left Control224
c6Left Shift225
v25Left Option226
z29Left Command227
Return40Right Control228
Escape41Right Shift229
Backspace42Right Option230
Tab43Right Command231
Space44F158
Right arrow79F1269
Left arrow80Down arrow81
Up arrow82