Documentation Index
Fetch the complete documentation index at: https://mintlify.com/LiveSplit/livesplit-core/llms.txt
Use this file to discover all available pages before exploring further.
Overview
HotkeySystem<S> registers global keyboard hotkeys that fire even when the application window is not focused, allowing runners to control the timer from any window. The type parameter S must implement CommandSink — in practice this is the SharedTimer wrapper that translates hotkey events into timer commands (split, reset, undo, etc.).
Hotkey support is platform-dependent. On platforms that do not support global hotkeys, the system is compiled in but all operations are no-ops. By default the HotkeySystem is activated immediately upon creation.
Construction
HotkeySystem::new(sink: S) -> Result<HotkeySystem<S>>
Creates a new HotkeySystem using the default HotkeyConfig (see the defaults table below). Returns an error if the platform does not support hotkeys or if registration fails.
HotkeySystem::with_config(sink: S, config: HotkeyConfig) -> Result<HotkeySystem<S>>
Creates a new HotkeySystem with a custom HotkeyConfig. Returns an error if the configuration contains duplicate hotkeys or if registration fails.
Activation
activate() -> Result<()>
Re-enables the hotkey system after it has been deactivated. If the system is already active, this is a no-op.
deactivate() -> Result<()>
Temporarily disables all hotkeys. No hotkey events are fired while deactivated. Use this while a settings dialog is open to prevent accidental splits.
Configuration
config() -> HotkeyConfig
Returns a copy of the HotkeyConfig currently in use.
set_config(config: HotkeyConfig) -> Result<()>
Replaces the active hotkey configuration. Each hotkey is re-registered. Returns an error if the new configuration has duplicate hotkeys (the same key assigned to more than one action). The previous configuration remains active if the call fails.
resolve(key_code: KeyCode) -> Cow<'static, str>
Resolves a KeyCode to its localized name according to the current keyboard layout. Useful for displaying hotkey labels to the user in the correct script. Returns a Cow<'static, str> — typically a 'static string slice but may be an owned String for dynamically resolved names.
HotkeyConfig Fields
HotkeyConfig is a plain struct with one Option<Hotkey> field per timer action. None means the action has no hotkey assigned.
| Field | Default | Action |
|---|---|---|
split | Numpad1 | Start the timer / split to the next segment |
reset | Numpad3 | Reset the current attempt |
undo | Numpad8 | Undo the last split |
skip | Numpad2 | Skip the current split without recording a time |
pause | Numpad5 | Pause / resume the timer; also starts a new attempt |
undo_all_pauses | None | Remove all accumulated pause time from the current attempt |
previous_comparison | Numpad4 | Switch to the previous comparison |
next_comparison | Numpad6 | Switch to the next comparison |
toggle_timing_method | None | Toggle between Real Time and Game Time |
HotkeyConfig derives Default, so HotkeyConfig::default() gives you the table above. It also derives Serialize/Deserialize for JSON persistence:
Full Example
C API
The C API uses aCommandSink (provided by the capi layer) as the HotkeySystem sink type. Hotkey configuration is managed through a separate HotkeyConfig opaque type.
| C function | Rust equivalent |
|---|---|
HotkeySystem_new(command_sink) | HotkeySystem::new(sink) |
HotkeySystem_with_config(command_sink, config) | HotkeySystem::with_config(sink, config) |
HotkeySystem_activate(this) | system.activate() — returns bool |
HotkeySystem_deactivate(this) | system.deactivate() — returns bool |
HotkeySystem_config(this) | system.config() — returns owned HotkeyConfig |
HotkeySystem_set_config(this, config) | system.set_config(config) — returns bool |
HotkeySystem_resolve(this, key_code) | system.resolve(key_code) |
HotkeySystem_drop(this) | drop(system) |
wasm-web feature, HotkeySystem_add_window(hotkey_system, window) is additionally available to forward keyboard events from a child Window object.