@@ -65,10 +65,17 @@ module Device
65
65
# hide_keyboard('Finished') # Close a keyboard with the 'Finished' button
66
66
# ```
67
67
68
- # @!method key_event
69
- # Send a key event to the device.
70
- # @param key (integer) The key to send.
71
- # @param metastate (String) The state the metakeys should be in when sending the key.
68
+ # @!method press_keycode
69
+ # Press keycode on the device.
70
+ # http://developer.android.com/reference/android/view/KeyEvent.html
71
+ # @param key (integer) The key to press.
72
+ # @param metastate (String) The state the metakeys should be in when pressing the key.
73
+
74
+ # @!method long_press_keycode
75
+ # Long press keycode on the device.
76
+ # http://developer.android.com/reference/android/view/KeyEvent.html
77
+ # @param key (integer) The key to long press.
78
+ # @param metastate (String) The state the metakeys should be in when long pressing the key.
72
79
73
80
# @!method push_file
74
81
# Place a file in a specific location on the device.
@@ -146,11 +153,19 @@ def hide_keyboard(close_key='Done')
146
153
end
147
154
end
148
155
149
- add_endpoint_method ( :key_event , 'session/:session_id/appium/device/keyevent ' ) do
150
- def key_event ( key , metastate = nil )
156
+ add_endpoint_method ( :press_keycode , 'session/:session_id/appium/device/press_keycode ' ) do
157
+ def press_keycode ( key , metastate = nil )
151
158
args = { keycode : key }
152
159
args [ :metastate ] = metastate if metastate
153
- execute :key_event , { } , args
160
+ execute :press_keycode , { } , args
161
+ end
162
+ end
163
+
164
+ add_endpoint_method ( :long_press_keycode , 'session/:session_id/appium/device/long_press_keycode' ) do
165
+ def long_press_keycode ( key , metastate = nil )
166
+ args = { keycode : key }
167
+ args [ :metastate ] = metastate if metastate
168
+ execute :long_press_keycode , { } , args
154
169
end
155
170
end
156
171
0 commit comments