Implemented key_up and key_down methods

Implemented key_up and key_down methods in GameIO
This commit is contained in:
Martysh12 2021-12-20 16:12:34 +02:00
parent 113d93773e
commit 05c29e7e72
1 changed files with 5 additions and 11 deletions

View File

@ -25,17 +25,17 @@ class AbstractGameIO(ABC):
"""Creates a screenshot, and returns it in Pillow format."""
pass
# TODO: Implement the following two functions in descendants.
# feel free to change these two functions in the descendants
@abstractmethod
def key_up(self, key: str):
"""Holds a key on a virtual keyboard."""
pass
pyautogui.keyUp(key)
@abstractmethod
def key_down(self, key: str):
"""Lets go of a key on a virtual keyboard."""
pass
pyautogui.keyDown(key)
def send_key(self, key: str):
"""Presses a key on a virtual keyboard."""
@ -52,10 +52,10 @@ class WindowsGameIO(AbstractGameIO):
return self.d.screenshot() # TODO: Cut this to self.loc(x, y, w, h)
def key_up(self, key: str):
pass
pyautogui.keyUp(key)
def key_down(self, key: str):
pass
pyautogui.keyDown(key)
class LinuxGameIO(AbstractGameIO):
@ -64,9 +64,3 @@ class LinuxGameIO(AbstractGameIO):
def fetch_sshot(self):
return pyautogui.screenshot(region=self.loc)
def key_up(self, key: str):
pass
def key_down(self, key: str):
pass