@@ -340,6 +340,23 @@ def hide_keyboard(self, key_name=None):
340340 self .execute (Command .HIDE_KEYBOARD , data )
341341 return self
342342
343+ # TODO: remove when new Appium is out
344+ def keyevent (self , keycode , metastate = None ):
345+ """Sends a keycode to the device. Android only. Possible keycodes can be
346+ found in http://developer.android.com/reference/android/view/KeyEvent.html.
347+
348+ :Args:
349+ - keycode - the keycode to be sent to the device
350+ - metastate - meta information about the keycode being sent
351+ """
352+ data = {
353+ 'keycode' : keycode ,
354+ }
355+ if metastate is not None :
356+ data ['metastate' ] = metastate
357+ self .execute (Command .KEY_EVENT , data )
358+ return self
359+
343360 def press_keycode (self , keycode , metastate = None ):
344361 """Sends a keycode to the device. Android only. Possible keycodes can be
345362 found in http://developer.android.com/reference/android/view/KeyEvent.html.
@@ -538,6 +555,9 @@ def _addCommands(self):
538555 ('POST' , '/session/$sessionId/touch/multi/perform' )
539556 self .command_executor ._commands [Command .GET_APP_STRINGS ] = \
540557 ('POST' , '/session/$sessionId/appium/app/strings' )
558+ # TODO: remove when new Appium is out
559+ self .command_executor ._commands [Command .KEY_EVENT ] = \
560+ ('POST' , '/session/$sessionId/appium/device/keyevent' )
541561 self .command_executor ._commands [Command .PRESS_KEYCODE ] = \
542562 ('POST' , '/session/$sessionId/appium/device/press_keycode' )
543563 self .command_executor ._commands [Command .LONG_PRESS_KEYCODE ] = \
0 commit comments