Skip to content

Fix garbled typing on Windows: use type() instead of per-char press/release#25

Open
obbax wants to merge 1 commit intogurjar1:mainfrom
obbax:fix/typing-garbled
Open

Fix garbled typing on Windows: use type() instead of per-char press/release#25
obbax wants to merge 1 commit intogurjar1:mainfrom
obbax:fix/typing-garbled

Conversation

@obbax
Copy link
Copy Markdown

@obbax obbax commented Mar 23, 2026

Problem

On Windows, the typing mechanism produces garbled/duplicated text because it uses keyboard_controller.press(char) + keyboard_controller.release(char) for each character individually. This is a known issue (#16, #15).

Root Cause

pynput's per-character press/release sends individual keydown/keyup events which get mangled by Windows keyboard buffering, especially on CPU (int8) with non-English languages.

Fix

Replaced the per-character loop with keyboard_controller.type(text_to_type) which uses Windows native text input API to type the entire string cleanly.

- for char in text_to_type:
-     if not self._is_running or self.stop_typing_event.is_set(): break
-     keyboard_controller.press(char)
-     keyboard_controller.release(char)
-     time.sleep(self.char_delay)
+ keyboard_controller.type(text_to_type)
+ time.sleep(0.05)

Testing

  • Tested on Samsung Galaxy Book (Intel Core Ultra 7, Windows 11 Pro)
  • Swedish dictation with 'small' and 'medium' models
  • Text types out cleanly without garbling
  • No additional dependencies required

…elease

The original code used keyboard_controller.press(char) + release(char)
for each character with a delay, which causes garbled/duplicated output
on Windows due to pynput's key event handling.

Replaced with keyboard_controller.type(text_to_type) which uses Windows
native text input API for clean, reliable typing.

Tested on Samsung Galaxy Book (Intel Core Ultra 7, Windows 11 Pro).
Swedish dictation works perfectly with this fix.

Fixes gurjar1#16, gurjar1#15
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

Successfully merging this pull request may close these issues.

1 participant