# 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[​](#usage "Direct link to Usage")

```
await browser.pressKeyCode(keycode, metastate, flags)
```

## Parameters[​](#parameters "Direct link to Parameters")

| Name                        | Type     | Details                                                     |
| --------------------------- | -------- | ----------------------------------------------------------- |
| `keycode`                   | `number` | The keycode to press (Android KeyEvent constant)            |
| `metastate`<br />*optional* | `number` | Meta state to apply during the key press (e.g. shift, ctrl) |
| `flags`<br />*optional*     | `number` | Integer flags for the key event                             |

## Example[​](#example "Direct link to 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 "Direct link to Support")

![Support for android](/assets/images/android-d941e94d5839760141de31c8446b67ce.svg)

**Supported platforms:** Android

note

Refer to the official [Appium driver documentation](https://appium.io/docs/en/latest/ecosystem/) to see which driver versions support this command.
