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

Cancelling double letters, even when they are separated #9

Open
CarlosRuiz-globalqss opened this issue Sep 12, 2024 · 2 comments
Open

Comments

@CarlosRuiz-globalqss
Copy link

Firstly I must say that I am a very fast typist.

So, the program is cancelling double letters when I type too fast.
For example "cancelling" turns out as "canceling", and "letters" turns out as "leters".
But that's understandable, if my second typing happens faster than the threshold.

The problem that I think it can be preventable is that the second letter is also cancelled even when is separated by another keystroke.

For example "even" becomes "evn", or "the elder" turns out as "the lder".

I don't know much about python to solve it myself, but I guess it can be something like, on every keystroke if the previous keystroke is different then cancel the threshold.

@finkrer
Copy link
Owner

finkrer commented Sep 12, 2024

Hi @CarlosRuiz-globalqss. That's a good point. Unfortunately, in my experience, being smart with keystrokes, especially when it comes to taking into accout speed or duration, usually backfires somewhere. Here, we have to be smart by necessity, and it will never work perfectly.

You could check the last key, sure. The issue is that, when typing fast, you can likely type the next letter in-between chatters, and the chatter will get through. As a fast typer, your presses likely overlap, so it's hard to say what's going on.

In any case, if you want to try it, it should be easy.

_last_key_up: Dict[libevdev.EventCode, int] = {}
_key_pressed: DefaultDict[libevdev.EventCode, bool] = defaultdict(bool)

Here, add

_last_key_code = None

if prev is None or now - prev > threshold * 1E3:

Then here, change the condition to

if prev is None or now - prev > threshold * 1E3 or _last_key_code != event.code:

_key_pressed[event.code] = True

And after this line, add

_last_key_code = event.code

This should work, you can try it for yourself and report if there are any issues. Also, you could try playing with the threshold value if you are typing very fast.

CarlosRuiz-globalqss added a commit to CarlosRuiz-globalqss/KeyboardChatteringFix-Linux that referenced this issue Sep 12, 2024
CarlosRuiz-globalqss added a commit to CarlosRuiz-globalqss/KeyboardChatteringFix-Linux that referenced this issue Sep 12, 2024
@CarlosRuiz-globalqss
Copy link
Author

Thanks @finkrer - opened pull request #10

Until now it seems working fine for the second case, the first case "letter -> leter" sounds very difficult to fix, as you advice the only option here would be to play with the threshold.

Thanks for your help, learnt a bit of python today :-)

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