keycastr / keycastr

KeyCastr, an open-source keystroke visualizer
BSD 3-Clause "New" or "Revised" License
12.82k stars 518 forks source link

Phantom Keystrokes Emitted After Closing KeyCastr #72

Closed sdeken closed 3 hours ago

sdeken commented 8 years ago

Looks like there's an issue in which keystrokes are being "held" by KeyCastr and broadcast into other applications when shutting KeyCastr down.

To recreate:

Expected Result: KeyCastr shuts down and the empty note in Notes is still empty.

Actual Result: The gibberish that was typed (some, but not all) is put into the empty note.

This appears to be caused by the initial keyboard tap that we create to check whether or not we can listen for the kCGEventKeyDown event. If we skip this check, the problem goes away.

akitchen commented 3 years ago

Changes on master in pursuit of v0.9.9 / #182 seem to have fixed this, mostly. It's down to one or two ghost keystrokes, from "many" (which I have also observed many times 😞)

I suspect [NSApp activateIgnoringOtherApps:YES]; may be the culprit, but more testing is needed!

akitchen commented 3 years ago

Hmm, maybe it's not fixed after all, I'm still seeing this behavior in some circumstances and it's not clear why.

MVFX-Zbiggy commented 2 months ago

The issue is still here and, from my experience, it's been present for as long as I've been using KeyCastr. No special steps needed to replicate on my end: 1) Open TextEdit, 2) Open KeyCastr, 3) Type something in TextEdit, 4) Close KeyCastr ( either via r-click in the dock or by focusing the app and pressing CMD+Q ), 5) TextEdit will receive a random number of the previously typed keystrokes. Attaching a video with the replication.

One weird thing though is that it never seems to repeat the very first keystroke 🤔

https://github.com/user-attachments/assets/568854c6-e75d-4fcf-b864-66de7da2c311