Ga68 / benign-key-logger

A simple, transparent, open-source key logger, written in Python, for tracking your own key-usage statistics.
106 stars 16 forks source link

Keys should be logged even if they had unbalanced key-up earlier #15

Open amacleod opened 5 months ago

amacleod commented 5 months ago

The behavior when key-down and key-up mismatch each other due to differing <shift> mod at the time of each event leads to lingering capital letters in the list of held keys. This in turn leads to key_down earlying-out when the same capital letter comes through again, losing that keystroke to the aether.

Hasty shift: shift-down, letter-down, shift-up, letter-up Un-hasty shift: shift-down, letter-down, letter-up, shift-up

I find that I use "hasty shift" at least half the time when I am capitalizing letters. I bet it is different for every typist.

This happens for any capital letter that I type in between the "hasty shift" behavior and the next time that capital letter is cleared from the list, either through garbage cleaning or through an un-hasty shift release of that same letter.

hasty-shift-up.txt

amacleod commented 5 months ago

I think the fix might be to remove capital letters from the held keys list when their lowercase equivalent is released. Same probably goes for any character that has a shifted and unshifted variant, like numbers and -/_ and so on.

resuna commented 2 months ago

I was just noting this and came to suggest a more liberal test, or clearing the modifier states in the held keys collection when the modifier goes away, or treating modifiers as just other held keys and re-parsing the held keys collection for logging.

2024-08-30 04:02:08.480 : INFO : key: T

2024-08-30 04:02:08.600 : WARNING : t up event without a paired down event

mosius-chwy commented 2 months ago

@resuna not following. ¿could you explain another way?

resuna commented 2 months ago

Instead of tracking the key registered as capital T, track the pair of "t" and "shift" as separate key-down and key-up events, that way when the "t" is released there's a "t" in the table that matches it.

sooheon commented 1 month ago

Instead of tracking the key registered as capital T, track the pair of "t" and "shift" as separate key-down and key-up events, that way when the "t" is released there's a "t" in the table that matches it.

I was just going to request this as a feature. I'm logging keys to track key presses, not letter insertions.

Relatedly, I'm seeing logs like <alt> + ∆, when I'm only typing <alt> + j.