@@ -350,6 +350,23 @@ def hide_keyboard(self, key_name=None, key=None, strategy=None):
350350 self .execute (Command .HIDE_KEYBOARD , data )
351351 return self
352352
353+ # Needed for Selendroid
354+ def keyevent (self , keycode , metastate = None ):
355+ """Sends a keycode to the device. Android only. Possible keycodes can be
356+ found in http://developer.android.com/reference/android/view/KeyEvent.html.
357+
358+ :Args:
359+ - keycode - the keycode to be sent to the device
360+ - metastate - meta information about the keycode being sent
361+ """
362+ data = {
363+ 'keycode' : keycode ,
364+ }
365+ if metastate is not None :
366+ data ['metastate' ] = metastate
367+ self .execute (Command .KEY_EVENT , data )
368+ return self
369+
353370 def press_keycode (self , keycode , metastate = None ):
354371 """Sends a keycode to the device. Android only. Possible keycodes can be
355372 found in http://developer.android.com/reference/android/view/KeyEvent.html.
@@ -640,6 +657,9 @@ def _addCommands(self):
640657 ('POST' , '/session/$sessionId/touch/multi/perform' )
641658 self .command_executor ._commands [Command .GET_APP_STRINGS ] = \
642659 ('POST' , '/session/$sessionId/appium/app/strings' )
660+ # Needed for Selendroid
661+ self .command_executor ._commands [Command .KEY_EVENT ] = \
662+ ('POST' , '/session/$sessionId/appium/device/keyevent' )
643663 self .command_executor ._commands [Command .PRESS_KEYCODE ] = \
644664 ('POST' , '/session/$sessionId/appium/device/press_keycode' )
645665 self .command_executor ._commands [Command .LONG_PRESS_KEYCODE ] = \
0 commit comments