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

'Hello world' becomes 'Helo world' #148

Closed
tvturnhout opened this issue Mar 30, 2018 · 2 comments
Closed

'Hello world' becomes 'Helo world' #148

tvturnhout opened this issue Mar 30, 2018 · 2 comments

Comments

@tvturnhout
Copy link

tvturnhout commented Mar 30, 2018

Having an issue where double letters are only typed once. Reproduced this error on two different PC's. Any experience with this?

@boppreh
Copy link
Owner

boppreh commented Mar 30, 2018

Thank you for the report. I can reproduce this issue, but it's strange. For the moment, a workaround is to use write('hello world', exact=False). This will send actual key events instead of typing the characters with OS-specific typing commands. It'll keep you from using characters not present in your keyboard, but fixes the double-letter issue.

Notes:

  • this only happens on Windows.
  • this only happens if using exact=True (which is the default option in Window), which relies on _os_keyboard.type_unicode.
  • putting a delay between events fixes the problem, but the delay required is enormous (e.g. write('hello world', delay=0.2)), with larger and larger requires for more repeated characters in a row.

@boppreh
Copy link
Owner

boppreh commented Mar 30, 2018

Found the problem. The "typing" events we use are different from key presses, and meant for alternative inputs like speech or handwriting. It allows programs to feed pieces of text to other programs, almost but not quite as if it was typed by a keyboard.

I believed those events were self-contained and stateless, but apparently they count as "key presses", and require a "key release". Just like you can type "ab" by holding "a" and pressing "b", keyboard was sending many "key press" events and no "key release", which kinda works but doesn't allow you to type repeated keys.

The solution was to duplicate all typing events, pairing them up with key releases.

If the problem persists, or if you find some related issue, feel free to comment here and I'll reopen the issue.

Thank you for the report!

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

No branches or pull requests

2 participants