Zum Hauptinhalt springen

pressKeyCode

Press a particular key on the device. The keycode values correspond to 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.pressKeyCode(keycode, metastate, flags)
Parameters
NameTypeDetails
keycodenumberThe keycode to press (Android KeyEvent constant)
metastate
optional
numberMeta state to apply during the key press (e.g. shift, ctrl)
flags
optional
numberInteger flags for the key event
Example
pressKeyCode.js
it('should press the Home button', async () => {
// Press the Home button (keycode 3)
await browser.pressKeyCode(3)
// Press with meta state (e.g., Shift + A = keycode 29, metastate 1)
await browser.pressKeyCode(29, 1)
})
Support

Support for android

Hinweis

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

Welcome! How can I help?

WebdriverIO AI Copilot