[GH-ISSUE #72] Phantom Keystrokes Emitted After Closing KeyCastr #58

Closed
opened 2026-05-05 04:49:46 -06:00 by gitea-mirror · 3 comments
Owner

Originally created by @sdeken on GitHub (Oct 10, 2016).
Original GitHub issue: https://github.com/keycastr/keycastr/issues/72

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:

  • Run Notes (so that junk keystrokes have somewhere to go)
  • Create a new note in Notes
  • Run KeyCastr
  • Make sure that KeyCastr is set to be shown in the Dock and Menu Bar
  • Make sure that KeyCastr is using the default visualizer (although I think the problem occurs with all visualizers)
  • Using the mouse, put the focus back on Notes
  • Using the mouse, put the focus back on KeyCastr
  • Type some gibberish into the KeyCastr window
  • Using the mouse, quit KeyCastr

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.

Originally created by @sdeken on GitHub (Oct 10, 2016). Original GitHub issue: https://github.com/keycastr/keycastr/issues/72 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: - Run Notes (so that junk keystrokes have somewhere to go) - Create a new note in Notes - Run KeyCastr - Make sure that KeyCastr is set to be shown in the Dock and Menu Bar - Make sure that KeyCastr is using the default visualizer (although I think the problem occurs with all visualizers) - Using the mouse, put the focus back on Notes - Using the mouse, put the focus back on KeyCastr - Type some gibberish into the KeyCastr window - Using the mouse, quit KeyCastr 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.
gitea-mirror 2026-05-05 04:49:46 -06:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@akitchen commented on GitHub (Dec 11, 2020):

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!

<!-- gh-comment-id:743461012 --> @akitchen commented on GitHub (Dec 11, 2020): 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!
Author
Owner

@akitchen commented on GitHub (Dec 14, 2020):

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

<!-- gh-comment-id:744130315 --> @akitchen commented on GitHub (Dec 14, 2020): Hmm, maybe it's not fixed after all, I'm still seeing this behavior in some circumstances and it's not clear why.
Author
Owner

@ghost commented on GitHub (Sep 16, 2024):

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

<!-- gh-comment-id:2352244639 --> @ghost commented on GitHub (Sep 16, 2024): 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
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/keycastr#58
No description provided.