Skip to content

Add time delay for key strokes in type command#64

Merged
Evidlo merged 3 commits intoEvidlo:masterfrom
XaverKlemenschits:delayedKeyboard
Jul 17, 2024
Merged

Add time delay for key strokes in type command#64
Evidlo merged 3 commits intoEvidlo:masterfrom
XaverKlemenschits:delayedKeyboard

Conversation

@XaverKlemenschits
Copy link
Copy Markdown
Contributor

I have been having the issue lately that single characters got lost when using type via a keybinding.
Especially web-interfaces seem to sometimes be too slow to register very short key presses.
E.g. instead of my username klemenschits, every third time or so it would only register klemnschits or klemenshits (the second one really hurts 😅 ). It is actually worse for passwords, because they are basically wrong at random.

Testing around, I found that this does not occur using the --xdotool flag.
The reason seems to be that xdotool uses a default key press duration of 12ms (see [1]).

I thought it would be useful to have the same behaviour using the pynput implementation and make it a command line flag. Testing this showed that with increased key stroke duration, it now works every time. Since this is not really easy to test, I cannot give a 100% guarantee that it now works every time, but it seems reasonable to me.

I have set the default to 12ms per keystroke (like xdotool), but I am open to change that default if there is a more reasonable one.

Curious to hear what you think 🙂

[1] https://askubuntu.com/questions/1098762/does-xdotool-key-delay-pause-for-specified-delay-between-typing-every-two-co

Xaver Klemenschits added 2 commits July 11, 2024 15:58
…ing pynput. Added --duration and --delay argument to 'type' tool to allow users to set key stroke duration and time between key strokes.
@Evidlo
Copy link
Copy Markdown
Owner

Evidlo commented Jul 13, 2024 via email

@XaverKlemenschits
Copy link
Copy Markdown
Contributor Author

XaverKlemenschits commented Jul 15, 2024

Good point. It is probably better to do this upstream.

There seems to be an open pull request on pynput [1] about this issue for 7 months now. It did not gain a lot of traction and I could not find a related issue, so not sure how long it will take to merge this. So either wait, or use the custom implementation for now and then switch to the pynput functionality once it is merged.

I added an issue in pynput to implement this, let's see how it goes : moses-palmer/pynput#606

[1] moses-palmer/pynput#579

@Evidlo
Copy link
Copy Markdown
Owner

Evidlo commented Jul 15, 2024

Thanks for putting the legwork in. I'll keep an eye on the pynput issue.

@Evidlo Evidlo merged commit 8d31f74 into Evidlo:master Jul 17, 2024
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.

2 participants