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

Cannot hold a key #643

Open
skkd113 opened this issue Mar 31, 2024 · 1 comment
Open

Cannot hold a key #643

skkd113 opened this issue Mar 31, 2024 · 1 comment

Comments

@skkd113
Copy link

skkd113 commented Mar 31, 2024

Hello there, by somehow i cannot hold a key with keyboard.press(), it just press once. Anyone know what is the issue?

keyboard.press('a')
time.sleep(5)
keyboard.release('a')

@jasonzampas
Copy link

This happens because the OS treats keyboard.press() and keyboard.release() as holding the key down, not pressing it repeatedly (unlike your physical keyboard). However, you can use this program below to do what you want to do:

duration = 5
end_time = time.time() + duration
 
while time.time() < end_time:
    keyboard.press('a')
    keyboard.release('a')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants