KR2 is a CLI tool that controls key repeat delay and repeat rate on Windows beyond the OS built-in limits.
The standard Windows maximum repeat rate is roughly 31 characters per second (~32 ms interval) via Control Panel, and the original KR tool uses FilterKeys which may be similarly capped by OS internals. KR2 bypasses these limits by intercepting keyboard events at a low level and generating its own repeats, enabling rates of 200+ cps in practice.
| Component | Role |
|---|---|
| WH_KEYBOARD_LL hook (main thread) | Intercepts all keyboard events system-wide. Passes first physical key-down through, suppresses OS-generated repeats. Tracks key state. |
| Repeat thread (dedicated) | High-resolution timer loop using QueryPerformanceCounter. For every key held past delay_ms, emits synthetic key-down events via SendInput every rate_ms. |
| Console handler | Catches Ctrl+C / window close for clean shutdown. |
| Named event IPC | Allows kr2 stop from another terminal to signal the running instance. |
The original KR uses SystemParametersInfo(SPI_SETFILTERKEYS) to set FILTERKEYS.iRepeatMSec. While this accepts values in milliseconds, the OS may internally clamp or ignore values below ~25–30 ms. The actual repeat behavior is mediated by the Windows input subsystem, which has its own limits.
KR2's hook+SendInput approach gives complete control over timing at user-mode level, with effectively no lower bound on the repeat interval (limited only by Sleep(1) ≈ 1 ms granularity).
# Set delay=200ms, rate=15ms (~67 chars/sec)
kr2 200 15
# Very fast: delay=100ms, rate=5ms (~200 chars/sec)
kr2 100 5
# Stop a running instance (from another terminal)
kr2 stop
# Check status (running state + auto-start info)
kr2 status
# Help / Version
kr2 --help
kr2 --version# Launch as a detached daemon – survives terminal close
kr2 200 15 --daemon
# Or short form
kr2 200 15 -dThe process detaches completely from the terminal. You can close the terminal and KR2 keeps running. Stop it from any terminal with:
kr2 stopkr2 statusShows whether KR2 is running (with PID, delay, rate) and whether auto-start is enabled.
# Enable auto-start with specific settings
kr2 startup enable 200 15
# Disable auto-start
kr2 startup disable
# Check current auto-start configuration
kr2 startupThis writes an entry to the Windows registry
(HKCU\Software\Microsoft\Windows\CurrentVersion\Run) so KR2 launches
automatically as a daemon on every login. No admin required.
| Parameter | Min | Max | Unit |
|---|---|---|---|
delay_ms |
0 | 5000 | milliseconds |
rate_ms |
1 | 2000 | milliseconds |
rate_ms=1→ theoretical 1000 cps (practical ~500–800 cps due to OS scheduling).rate_ms=5→ ~200 cps (excellent for fast typing/editing).rate_ms=15→ ~67 cps (already 2× faster than Windows' max via UI).
# Install toolchain (once)
pacman -S --needed mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-make
# Build
mingw32-make
# Or directly
gcc -O2 -Wall -Wextra -pedantic -DWIN32_LEAN_AND_MEAN -s -o kr2.exe kr2.c -luser32 -lwinmm -ladvapi32cl /O2 /W4 /Fe:kr2.exe kr2.c user32.lib winmm.lib advapi32.lib- Windows 7, 10, 11 (any edition)
- No drivers required
- No administrator privileges required
- Works with any keyboard layout
| Issue | Details |
|---|---|
| Anti-cheat | Games with anti-cheat (EAC, BattlEye) may detect/block WH_KEYBOARD_LL hooks or SendInput. KR2 is designed for productivity use. |
| UIPI | SendInput from a non-elevated process cannot target elevated (Run as Administrator) windows. Run KR2 as admin if needed. |
| CPU usage | The repeat thread wakes ~1000×/sec (Sleep(1)), iterates 256 entries. CPU usage is negligible (<0.1%). |
| Precision | At rate_ms < 3, timing jitter from OS scheduling becomes noticeable, but throughput remains very high. |
| Persistence | KR2 requires a running process. Use --daemon to detach from terminal. Use kr2 startup enable for auto-start across reboots. |
| Feature | KR (FilterKeys) | KR2 (Hook+SendInput) |
|---|---|---|
| Mechanism | SPI_SETFILTERKEYS |
WH_KEYBOARD_LL + SendInput |
| Max effective rate | ~30 cps (OS-limited) | ~1000 cps (user-mode limit) |
| Requires running process | No (system setting) | Yes |
| Persist after reboot | Yes (--persist) |
Yes (kr2 startup enable) |
| Backup/restore | Yes | Not needed (no system changes) |
| Modifier handling | OS handles | Explicit (pass-through) |
| Win7 / Win10 / Win11 | Yes | Yes |
| Admin required | Sometimes | No |
| Anti-cheat safe | Yes | May be flagged |
KR2 has built-in auto-start management via the Windows registry
(HKCU\Software\Microsoft\Windows\CurrentVersion\Run).
# Enable auto-start with your preferred settings
kr2 startup enable 200 15
# Check current auto-start configuration
kr2 startup
# Disable auto-start
kr2 startup disableWhen enabled, KR2 launches automatically as a daemon on every login. No admin privileges required. The entry is visible in Task Manager → Startup (Win10/11) or msconfig (Win7).
If you prefer not to use the built-in command:
- Press
Win+R, typeshell:startup, press Enter. - Create a shortcut to
kr2.exe 200 15 --daemon(adjust values).
schtasks /create /tn "KR2" /tr "C:\path\to\kr2.exe 200 15 --daemon" /sc onlogon /rl limitedLicensed under the Mozilla Public License 2.0 (MPL-2.0).