Send key event (FR)

Perfecto Command

mobile:key:event

Purpose

Sends a keyboard event to the device. Uses standard Android keycodes. For example:

Key code = 29 and the Metastate = 1 will print an "A"

Key code = 29 and the Metastate = 0 will print an "a"

Key codes and metastates are defined by Android.

Parameters

Name Type Possible Values Description
key Integer See Key codes page (Required) The key code key event to send to the device.
metastate Integer See Metastate page The metastate key event to send to the device.

Return Value

true - if successful

Exceptions

None

Examples

Copy

Java sample

Map<String, Object> pars = new HashMap<>();
pars.put("key", "29");
pars.put("metastate", "0");
String reStr = (String) driver.executeScript("mobile:key:event", pars);
Copy

C# sample

Dictionary<String, Object> pars = new Dictionary<String, Object>();
pars.Add("key", "32");
String reStr = (String) driver.ExecuteScript("mobile:key:event", pars);