sendKeyEvent
Send a key event to the Android device.
This command is the legacy Android key event API. For new tests, prefer using
pressKeyCode() with numeric keycodes from the Android KeyEvent constants.
Note: Falls back to the deprecated Appium 2 protocol endpoint if the driver does not support the
mobile:execute method.
Usage
browser.sendKeyEvent(keycode, metastate)
Parameters
| Name | Type | Details |
|---|---|---|
keycode | string | The keycode to send (as a string, e.g. '3' for Home). See Android KeyEvent for all available keycodes. |
metastateoptional | string | The meta state to apply during the key press as a string (e.g. '1' for Shift). See Android KeyEvent for all meta state values. |
Example
sendKeyEvent.js
it('should send a key event', async () => {
// Send the Home key event (keycode '3')
await browser.sendKeyEvent('3')
// Send Shift+A (keycode '29', metastate '1')
await browser.sendKeyEvent('29', '1')
})
Support
குறிப்பு
Refer to the official Appium driver documentation to see which driver versions support this command.