Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Key Repeating feature! #799

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions pyautogui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,25 @@ def mouseDown(x=None, y=None, button=PRIMARY, duration=0.0, tween=linear, logScr
_logScreenshot(logScreenshot, "mouseDown", "%s,%s" % (x, y), folder=".")
platformModule._mouseDown(x, y, button)

@_genericPyAutoGUIChecks
def KeyRepeat(key, hold_time, pause=0.1):
"""Performs continuous Key Repeatition.
For eg: Like in a text editor when you keep a key pressed, it repeats.

Args:
key (string): The key to be pressed. Check the valid key names in KEYBOARD.KEYS
hold_time (float): The duration of key repeatition
interval (float): Interval between each repition

Returns:
None
"""
# *Important Note: The reason I'm implementing is because KeyDown function does NOT perform this as you might expect.
PAUSE = pause
start = time.time()
while time.time() - start < hold_time:
press(key)
PAUSE = 0.1

@_genericPyAutoGUIChecks
def mouseUp(x=None, y=None, button=PRIMARY, duration=0.0, tween=linear, logScreenshot=None, _pause=True):
Expand Down