Skip to content

fix: hold key continuously at 100% duty keyboard mode (#191)#202

Open
wydvoy wants to merge 3 commits into
Blur009:devfrom
wydvoy:fix/keyboard-100-hold
Open

fix: hold key continuously at 100% duty keyboard mode (#191)#202
wydvoy wants to merge 3 commits into
Blur009:devfrom
wydvoy:fix/keyboard-100-hold

Conversation

@wydvoy
Copy link
Copy Markdown
Contributor

@wydvoy wydvoy commented May 20, 2026

Summary

Fixes #191. At 100% Click Duration in single-keyboard mode the engine was sending a KEYDOWN/KEYUP pair per cycle, which target apps see as a rapid tap rather than a held key. This PR rewires that path to a true Win32 hold:

  • One initial WM_KEYDOWN (with Shift held first if uppercase is on)
  • Repeated WM_KEYDOWN events per cycle — matches the Windows auto-repeat shape (keyboard input docs)
  • A single WM_KEYUP on stop

The new KeyboardHold guard owns the release, so panic/early-return paths still let the key go via Drop.

The gate is intentionally narrow — input_type=keyboard, key_code set, double-click disabled, duty >= 100%. Anything else keeps the existing per-cycle behavior.

Changes

  • src-tauri/src/engine/keyboard.rs — add KeyboardHold (idempotent release + Drop) and hold_key helper
  • src-tauri/src/engine/worker.rs — detect the 100% keyboard-hold case, take/release the hold across batches, count repeats correctly so click_count stays consistent

Test plan

  • cargo test — 39 passed (4 new keyboard-hold tests)
  • cargo fmt --check
  • cargo clippy --all-targets -- -D warnings
  • npm run lint
  • npm run frontend:build
  • Manual smoke against https://www.keyboardtester.com/tester.html — key registers as held, releases cleanly on stop

Kohles, Louis Marlon added 3 commits May 20, 2026 10:45
At 100% duty in single-keyboard mode, the engine was emitting
KEYDOWN/KEYUP pairs per cycle instead of holding the key down.
Switch this path to a true Win32 hold: one initial WM_KEYDOWN
(plus Shift for uppercase), repeated WM_KEYDOWN events per
cycle, and a single WM_KEYUP on stop. KeyboardHold owns the
release so panic/early-return paths still let the key go.
@Blur009
Copy link
Copy Markdown
Owner

Blur009 commented May 21, 2026

I don't quite see the point here personally. reducing your click speed to once a day will just hold the key down for an entire day and you will have the same effect as what you are trying to accomplish, no? @wydvoy

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