Hoppa till huvudinnehåll
🇺🇦  We stand with the people of Ukraine. We encourage compassion, and hope for peace.   🇺🇦
Please support humanitarian efforts for the Ukraine crisis through the International Committee of the Red Cross! #StandWithUkraine

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
NameTypeDetails
keycodestringThe keycode to send (as a string, e.g. '3' for Home). See Android KeyEvent for all available keycodes.
metastate
optional
stringThe 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

Support for android

anteckning

Refer to the official Appium driver documentation to see which driver versions support this command.

Welcome! How can I help?

WebdriverIO AI Copilot
Morty Proxy This is a proxified and sanitized view of the page, visit original site.