Press and hold a particular key on an Android Device.

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

Usage

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

Example

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

  'long press g (keycode 35) with ES6 async/await': async function (app) {
    await app.appium.longPressKeyCode(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