Skip to content

bortoloso/kr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KR (KeyRate)

Small Windows CLI tool to control key repeat delay and repeat rate (repeat interval) in milliseconds, inspired by Linux:

  • xset r rate <delay_ms> <repeat_ms>

KR uses Windows FilterKeys (SystemParametersInfo(SPI_SETFILTERKEYS)) to apply values and can optionally persist changes, backup current settings, and restore them later.

A GitHub Release will provide a prebuilt kr.exe, so most users won't need to compile.


TL;DR (Usage)

Set delay + rate (ms)

kr 220 15

Persist settings (recommended)

kr 220 15 --persist

Backup current settings then apply

kr 220 15 --backup --persist

Disable KR effect (return control to Windows slider/settings)

kr disable --persist

Restore from backup

kr --restore --persist

Show help / version

kr --help
kr --version

Limits (enforced)

KR enforces “human-friendly” safety limits:

  • delay_ms: 0..5000
  • rate_ms : 5..2000

If you want different limits, edit these macros in kr.c:

  • DELAY_MIN_MS, DELAY_MAX_MS
  • RATE_MIN_MS, RATE_MAX_MS

What do the numbers mean?

  • delay_ms: time in milliseconds before a held key starts repeating.
  • rate_ms: time in milliseconds between repeats once repetition begins.
    • Smaller rate_ms ⇒ faster repetition.

This matches Linux xset r rate delay repeat semantics (where the second number is the repeat interval in ms).


How KR applies changes (Windows details)

KR changes keyboard repeat behavior through Windows FilterKeys:

  • Setting values enables FilterKeys (FKF_FILTERKEYSON) and writes:
    • FILTERKEYS.iDelayMSec
    • FILTERKEYS.iRepeatMSec
  • kr disable turns FilterKeys OFF (clears FKF_FILTERKEYSON) so the default Windows keyboard repeat settings UI/slider regain control (with Windows' official limits).

Limitations: Actual repeat behavior may still be constrained by keyboard hardware, drivers, remote desktop, accessibility policies, or OS internals.


Installation (recommended)

Option A: Put kr.exe in a dedicated tools folder and add to PATH

  1. Download kr.exe from the GitHub Releases page.
  2. Create a folder for user tools, e.g.:
    • C:\Users\<you>\bin\
    • or C:\Tools\KR\
  3. Move kr.exe into that folder.
  4. Add the folder to your User PATH (recommended, no admin required):

Windows 10/11 (GUI)

  • Settings → System → About → Advanced system settings
  • Environment Variables…
  • Under “User variables”, select Path → Edit → New
  • Add the folder (e.g. C:\Users\<you>\bin\)
  • Open a new terminal and run:
    kr --help

PowerShell (User PATH)

$dir = "$env:USERPROFILE\bin"
New-Item -ItemType Directory -Force -Path $dir | Out-Null
# Move kr.exe to $dir manually or via script.
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";" + $dir, "User")

Close and reopen the terminal afterward.

Option B: Local folder usage (no PATH changes)

Just keep kr.exe in a folder and call it with a relative/absolute path:

C:\Tools\KR\kr.exe 220 15 --persist

Backup & Restore

KR can store a backup of your current FilterKeys configuration:

  • Backup location (per-user):
    %APPDATA%\kr\backup.bin

Workflow:

  1. Save backup + apply:
    kr 220 15 --backup --persist
  2. Later restore:
    kr --restore --persist

Build from source (Windows, open source toolchain)

KR is a single C file (kr.c). The most reproducible open source way to build on Windows is MSYS2 + MinGW-w64 (UCRT64).

1) Install MSYS2

Download and install MSYS2 from:

2) Update MSYS2

Open the installed terminal:

  • MSYS2 UCRT64 (important)

Then run:

pacman -Syu

If it asks you to close/reopen the terminal, do it, then run again:

pacman -Syu

3) Install the compiler (UCRT64)

In MSYS2 UCRT64:

pacman -S --needed mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-make

4) Compile

Using the Makefile

In MSYS2, GNU Make is commonly available as mingw32-make.exe.

From the repo root:

mingw32-make

Clean:

mingw32-make clean

Or compile directly with gcc

gcc -O2 -Wall -Wextra -pedantic  -DWIN32_LEAN_AND_MEAN -s -o kr.exe kr.c -luser32 -lshell32 -lole32 -luuid

The resulting kr.exe will be in the current directory.


Common problems and fixes

“‘make’ not found” but mingw32-make exists

Use:

mingw32-make

(You can also alias make=mingw32-make if you prefer.)

Linker errors about CoTaskMemFree or FOLDERID_RoamingAppData

Ensure you link with:

  • -lole32 -luuid (in addition to -lshell32)

The provided Makefile already includes these.

“Permission denied” or settings don't apply

  • Try running your terminal as Administrator and test again.
  • Some environments (corporate policy, accessibility lockdown, remote desktop) may restrict changing system parameters.

Changes apply but feel unchanged

Windows repeat behavior can be constrained by:

  • keyboard/driver limits
  • remote desktop / virtualization
  • accessibility settings
  • certain input method editors (IME)

Try testing locally (not over RDP) and verifying kr disable returns behavior to the Windows slider.


License

Licensed under the Mozilla Public License 2.0 (MPL-2.0). See LICENSE.

About

KR (KeyRate) - a tiny Windows CLI to set keyboard repeat delay and repeat rate (xset-like), with backup/restore, persistence, and a disable mode that returns control to the Windows slider.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors