| 20 | |
| 21 | |
| 22 | class KeyInput(InputDevice): |
| 23 | def __init__(self, name: str) -> None: |
| 24 | super().__init__() |
| 25 | self.name = name |
| 26 | self.type = interaction.KEY |
| 27 | |
| 28 | def encode(self) -> dict: |
| 29 | return {"type": self.type, "id": self.name, "actions": [acts.encode() for acts in self.actions]} |
| 30 | |
| 31 | def create_key_down(self, key) -> None: |
| 32 | self.add_action(TypingInteraction(self, "keyDown", key)) |
| 33 | |
| 34 | def create_key_up(self, key) -> None: |
| 35 | self.add_action(TypingInteraction(self, "keyUp", key)) |
| 36 | |
| 37 | def create_pause(self, pause_duration: float = 0) -> None: |
| 38 | self.add_action(Pause(self, pause_duration)) |
| 39 | |
| 40 | |
| 41 | class TypingInteraction(Interaction): |
no outgoing calls