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)
| 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: |
no test coverage detected