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

key_wait method does not work as expected #266

Closed
spyoungtech opened this issue Feb 28, 2024 · 0 comments · Fixed by #267
Closed

key_wait method does not work as expected #266

spyoungtech opened this issue Feb 28, 2024 · 0 comments · Fixed by #267
Labels
bug Something isn't working

Comments

@spyoungtech
Copy link
Owner

spyoungtech commented Feb 28, 2024

key_wait seems to return immediately, rather than actually waiting for the key.

Additionally, the return values are different in AHK v1 versus AHK v2. In v1, a return value of 1 means there was a timeout, in v2, the opposite is true.

Lastly, a TimeoutError is never raised in any circumstance, contradicting the README documentation.

It's unclear how long this has been broken, but it has been broken for at least 6 months.

To smooth over the API differences between v1 and v2, the proposal is that key_wait be modified to:

  • return a bool, rather than an int: False will mean there was a timeout and True will mean the key was pressed. This more closely resembles the v2 behavior
  • not raise a TimeoutError

The API usage will now look like:

if key_wait(key, timeout=1):
    print(key, 'was pressed')
else:
    print(key, 'was not pressed')

Technically, this is a breaking change for AHK v1 users... but since key_wait has seemingly been broken for over 6 months, it probably doesn't matter that much.

@spyoungtech spyoungtech added the bug Something isn't working label Feb 28, 2024
spyoungtech added a commit that referenced this issue Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant