From 7d0771832658d9eb17c7f60d47b6b527732d1e77 Mon Sep 17 00:00:00 2001 From: John McCardle Date: Tue, 21 Dec 2021 00:58:59 -0500 Subject: [PATCH] Inheriting cross-platform keyboard methods (non-abstract) --- gameio.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/gameio.py b/gameio.py index c18a035..4b0602e 100644 --- a/gameio.py +++ b/gameio.py @@ -27,20 +27,17 @@ class AbstractGameIO(ABC): # feel free to change these two functions in the descendants - @abstractmethod def key_up(self, key: str): """Holds a key on a virtual keyboard.""" pyautogui.keyUp(key) - @abstractmethod def key_down(self, key: str): """Lets go of a key on a virtual keyboard.""" pyautogui.keyDown(key) def send_key(self, key: str): """Presses a key on a virtual keyboard.""" - self.key_up(key) - self.key_down(key) + pyautogui.press(key) class WindowsGameIO(AbstractGameIO): @@ -51,12 +48,6 @@ class WindowsGameIO(AbstractGameIO): def fetch_sshot(self): return self.d.screenshot() # TODO: Cut this to self.loc(x, y, w, h) - def key_up(self, key: str): - pyautogui.keyUp(key) - - def key_down(self, key: str): - pyautogui.keyDown(key) - class LinuxGameIO(AbstractGameIO): def __init__(self):