@@ -337,7 +337,7 @@ def hide_keyboard(self, key_name=None):
337337 self .execute (Command .HIDE_KEYBOARD , data )
338338 return self
339339
340- def keyevent (self , keycode , metastate = None ):
340+ def press_keycode (self , keycode , metastate = None ):
341341 """Sends a keycode to the device. Android only. Possible keycodes can be
342342 found in http://developer.android.com/reference/android/view/KeyEvent.html.
343343
@@ -353,6 +353,22 @@ def keyevent(self, keycode, metastate=None):
353353 self .execute (Command .KEY_EVENT , data )
354354 return self
355355
356+ def long_press_keycode (self , keycode , metastate = None ):
357+ """Sends a long press of keycode to the device. Android only. Possible keycodes can be
358+ found in http://developer.android.com/reference/android/view/KeyEvent.html.
359+
360+ :Args:
361+ - keycode - the keycode to be sent to the device
362+ - metastate - meta information about the keycode being sent
363+ """
364+ data = {
365+ 'keycode' : keycode
366+ }
367+ if metastate != None :
368+ data ['metastate' ] = metastate
369+ self .execute (Command .LONG_PRESS_KEYCODE , data )
370+ return self
371+
356372 @property
357373 def current_activity (self ):
358374 """Retrieves the current activity on the device.
@@ -519,8 +535,10 @@ def _addCommands(self):
519535 ('POST' , '/session/$sessionId/touch/multi/perform' )
520536 self .command_executor ._commands [Command .GET_APP_STRINGS ] = \
521537 ('GET' , '/session/$sessionId/appium/app/strings' )
522- self .command_executor ._commands [Command .KEY_EVENT ] = \
523- ('POST' , '/session/$sessionId/appium/device/keyevent' )
538+ self .command_executor ._commands [Command .PRESS_KEYCODE ] = \
539+ ('POST' , '/session/$sessionId/appium/device/press_keycode' )
540+ self .command_executor ._commands [Command .LONG_PRESS_KEYCODE ] = \
541+ ('POST' , '/session/$sessionId/appium/device/long_press_keycode' )
524542 self .command_executor ._commands [Command .GET_CURRENT_ACTIVITY ] = \
525543 ('GET' , '/session/$sessionId/appium/device/current_activity' )
526544 self .command_executor ._commands [Command .SET_IMMEDIATE_VALUE ] = \
0 commit comments