Skip to content

feat: make key repeat delay and interval configurable - #469

Open
rengers wants to merge 1 commit into
feschber:mainfrom
rengers:configurable-key-repeat
Open

feat: make key repeat delay and interval configurable#469
rengers wants to merge 1 commit into
feschber:mainfrom
rengers:configurable-key-repeat

Conversation

@rengers

@rengers rengers commented Jul 18, 2026

Copy link
Copy Markdown

Summary

On macOS and Windows the OS does not auto-repeat synthetic key events, so
lan-mouse regenerates key repeats itself. The repeat delay and interval were
hardcoded to 500 ms / 32 ms, which can feel off compared to the sender's own
keyboard settings. This makes both values configurable, defaulting to the
current behaviour when unset.

Changes

  • input-emulation: add EmulationOptions { key_repeat_delay, key_repeat_interval } (with Default = 500 ms / 32 ms, exposed via
    DEFAULT_KEY_REPEAT_DELAY / DEFAULT_KEY_REPEAT_INTERVAL) and thread it
    through InputEmulation::new / with_backend into the macOS and Windows
    backends, replacing the per-backend hardcoded constants. The other backends
    leave key repeat to the OS and ignore the value (guarded so there are no
    unused-variable warnings on those targets).
  • config: add optional key_repeat_delay / key_repeat_interval
    (milliseconds) and a Config::emulation_options() accessor that maps them
    onto EmulationOptions, falling back to the defaults per field.
  • docs: document the options in config.toml and the README.

There is no behaviour change unless the new keys are set.

# milliseconds; only the macOS and Windows backends use these
key_repeat_delay = 300
key_repeat_interval = 20

Test plan

  • cargo fmt --all — clean
  • cargo clippy -p input-emulation --no-default-features --all-targets -- -D warnings — clean
  • root crate cargo check --no-default-features — clean (macOS)
  • CI: cargo fmt / clippy / test --workspace --all-targets --all-features
    on Linux + the Windows emulation backend. I could not build --all-features
    locally: the gtk frontend pulls in libadwaita, which does not link on my
    macOS/nix toolchain, so the Linux backends and the Windows path are only
    compile-checked by mirroring the macOS change.

The macOS and Windows emulation backends regenerate key repeats themselves
(the OS does not auto-repeat synthetic key events), but the repeat delay and
interval were hardcoded to 500 ms / 32 ms. Add `key_repeat_delay` and
`key_repeat_interval` config options (in milliseconds) so they can be tuned,
falling back to the previous defaults when unset.

- input-emulation: add `EmulationOptions` (Default = 500 ms / 32 ms) and thread
  it through `InputEmulation::new` / `with_backend` into the macOS and Windows
  backends. Other backends leave key repeat to the OS and ignore it.
- config: add the two optional fields and a `Config::emulation_options()`
  accessor that maps them onto `EmulationOptions`.
- document the new options in config.toml and the README.
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.

1 participant