Skip to content

fix: stop Escape from playing the error sound when closing capture - #393

Merged
lzhgus merged 1 commit into
mainfrom
fix/escape-overlay-beep
Nov 5, 2026
Merged

lzhgus merged 1 commit into
mainfrom
fix/escape-overlay-beep

Conversation

@lzhgus

@lzhgus lzhgus commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Fixes #356

Summary

  • Root cause: the capture overlay's local key monitor returned self?.handleLocalKeyEvent(event) ?? event. A nil result means "consumed", but ?? event turned it back into the event, so nothing the overlay handled was consumed. After Escape closed the overlay, the event kept going through AppKit with no key window left, and -[NSApplication sendEvent:] played the alert sound.
  • Holding Escape beeped again for every autorepeat, because the rest of the press still goes to Capso after the overlay is gone. The new EscapeKeyPressSwallower drops the autorepeats and keyUp of the press that closed an overlay. The next press is let through as usual. The Quick Access card's Escape button uses it too.
  • Side effect, now fixed: in multi-window selection, Escape is meant to clear the selection first. Because the event leaked through to the view, it then cancelled the whole capture as well. It now only clears the selection.
  • The annotation editor's tool-shortcut monitor had the same ?? event pattern and is fixed too.

Validation

  • Reproduced on a real build with synthesized HID key events and an injected hook that logs NSBeep. Before the fix: one beep per tap, plus one per autorepeat while holding Escape, matching the report.
  • After the fix: Capture Area, All-in-One, and the Quick Access card (Fullscreen) play no sound on a tap or when holding Escape (6 autorepeats). The previous front app gets the next Escape as usual.
  • Capture Window was not run end to end, because the local debug build lacked Screen Recording permission. It uses the same overlay window and key monitor as Capture Area.
  • New tests: EscapeKeyPressFilterTests, EscapeKeyPressSwallowerTests, and two CaptureOverlayInteractionTests that call the installed monitor handler. Both overlay tests fail with the old ?? event code.
  • The full CapsoTests suite passes locally (244 tests).

🤖 Generated with Claude Code

The capture overlay's local key monitor returned
`self?.handleLocalKeyEvent(event) ?? event`, which turns a nil result
("consumed") back into the event. After Escape closed the overlay, the
event kept going through AppKit with no key window left, which played
the system alert sound. Holding Escape beeped again for every
autorepeat, since those still go to Capso after the overlay is gone.

- Return the monitor's result as is, so handled keys are consumed.
- Swallow the autorepeats and keyUp of the Escape press that closed an
  overlay or the Quick Access card.
- Fix the same `?? event` pattern in the annotation tool shortcut
  monitor.

Fixes #356

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lzhgus
lzhgus merged commit 1ed6257 into main Nov 5, 2026
5 checks passed
@lzhgus
lzhgus deleted the fix/escape-overlay-beep branch November 5, 2026 06:33
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.

[Bug] Escape in Capture Window mode plays error sound

1 participant