Press a particular key on an Android Device.

See official Android Developers docs for reference of available Android key code values.

Usage

                    .appium.pressKeyCode(keycode, [callback])
                
                    .appium.pressKeyCode(keycode, metastate, flags, [callback])
                

Example

module.exports = {
  'press e with caps lock on (keycode 33 and metastate 1048576)': function (app) {
    app
      .appium.pressKeyCode(33, 1048576);
  },

  'press g (keycode 35) with ES6 async/await': async function (app) {
    await app.appium.pressKeyCode(35);
  }
};

Parameters

Name Type description
keycode number

Key code to press on the device.

metastate
Optional
number

Meta state to press the keycode with.

flags
Optional
number

Flags for the keypress.

callback
Optional
function

Optional callback function to be called when the command finishes.

See also