Skip to content

Add ctrl+alt+r global hotkey to start/stop recording - #14

Open
Broyojo wants to merge 5 commits into
mainfrom
feat/global-record-hotkey
Open

Add ctrl+alt+r global hotkey to start/stop recording#14
Broyojo wants to merge 5 commits into
mainfrom
feat/global-record-hotkey

Conversation

@Broyojo

@Broyojo Broyojo commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

What

Adds a global ctrl+alt+r hotkey to toggle recording, so you don't have to click the GUI/tray (which pollutes the recording with DuckTrack's own UI interactions).

  • The hotkey callback fires on a pynput listener thread, so it emits a Qt signal (toggle_record_requested) to run toggle_record safely on the main thread.
  • KeyCombinationListener now folds left/right modifier variants (ctrl_l, alt_r, ...) into their generic key, so combinations match reliably across platforms. This also benefits the existing shift+esc playback stop combo.
  • Documented in the README.

Notes

Credit

Feature design from the jxbb824/DuckTrack fork by @jxbb824, including the Qt-signal thread-safety pattern. Reimplemented on the existing pynput listener instead of the fork's keyboard library, which requires root privileges on macOS/Linux and globally suppresses the combo.

🤖 Generated with Claude Code

ruiqurm and others added 4 commits July 21, 2026 23:02
- Retry the OBS websocket connection with a readiness probe, since OBS
  may still be starting up when DuckTrack launches it
- Launch OBS via `open -a` on macOS so permission prompts work, and quit
  it gracefully via AppleScript (terminating the `open` process does nothing)
- Continue with the current OBS profile instead of crashing when the
  computer_tracker profile can't be created or switched to
- Show a one-time notice on macOS explaining the required permissions

Adapted from the huyouare/DuckTrack fork.

Co-authored-by: Jesse Hu <3528340+huyouare@users.noreply.github.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The hotkey listener runs on a pynput listener thread, so it emits a Qt
signal to make toggle_record run on the main thread. Left/right modifier
variants (ctrl_l, alt_r, ...) are folded into their generic key so
combinations match across platforms.

Feature adapted from the jxbb824/DuckTrack fork, reimplemented with the
existing pynput-based listener instead of the `keyboard` library, which
requires root on macOS and Linux.

Co-authored-by: Xirui Jiang <xirui@umich.edu>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Held modifiers change the character pynput reports (ctrl+r arrives as
'\x12' on Windows, alt+r as '®' on macOS), which breaks naive key-set
matching. GlobalHotKeys handles this internally for the record hotkey,
and KeyCombinationListener now normalizes via listener.canonical() for
the shift+esc playback combo.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
pynput's listener.canonical() converts special keys like Key.esc into
bare vk KeyCodes, so canonicalizing only the incoming presses broke
matching against combos stored as Key values. Canonicalize the combo
keys at registration time too, so both sides compare in canonical form.

Caught by the new tests, which cover generic and left/right modifier
variants, shifted characters, release handling, and the <ctrl>+<alt>+r
hotkey spec used in app.py.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Broyojo

Broyojo commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator Author

Added unit tests for the combo listener (tests/test_keycomb.py, runnable with uv run pytest once #15 lands). They immediately caught a real bug: listener.canonical() turns special keys like Key.esc into bare vk KeyCodes, which broke matching against combos stored as Key values — fixed by canonicalizing the stored combos at registration time as well. All 6 tests pass.

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.

2 participants