MCPcopy Create free account
hub / github.com/dtmilano/AndroidViewClient / command

Method command

src/com/dtmilano/android/culebron.py:1086–1104  ·  view source on GitHub ↗

Presses a key. Generates the actual key press on the device and prints the line in the script. :param keycode the keycode name

(self, keycode: str)

Source from the content-addressed store, hash-verified

1084 self.showPopupMenu(event)
1085
1086 def command(self, keycode: str) -> None:
1087 """
1088 Presses a key.
1089 Generates the actual key press on the device and prints the line in the script.
1090
1091 :param keycode the keycode name
1092 """
1093
1094 if self.vc.uiAutomatorHelper:
1095 try:
1096 if not keycode.startswith('KEYCODE_'):
1097 keycode = f'KEYCODE_{keycode}'
1098 self.vc.uiAutomatorHelper.ui_device.press_key_code(KEY_EVENT[f'{keycode}'])
1099 self.printOperation(None, Operation.PRESS_UI_AUTOMATOR_HELPER, keycode)
1100 except Exception as e:
1101 print(e, file=sys.stderr)
1102 else:
1103 self.device.press(keycode)
1104 self.printOperation(None, Operation.PRESS, keycode)
1105
1106 def onKeyPressed(self, event):
1107 if DEBUG_KEY:

Callers 2

onKeyPressedMethod · 0.95

Calls 2

press_key_codeMethod · 0.80
pressMethod · 0.45

Tested by

no test coverage detected