Skip to content

Component KeybindingInput

MeowLynxSea edited this page Jun 18, 2026 · 5 revisions

KeybindingInput

A text input that records the next keystroke as a keybinding combo when in Capturing mode.

use yororen_ui::headless::keybinding_input::{keybinding_input, KeybindingInputMode};

keybinding_input("bind-save")
    .placeholder("Press a key combo…")
    .mode(KeybindingInputMode::Idle)
    .on_change({
        let entity = cx.entity();
        move |new: &str, _, cx| entity.update(cx, |s, _| s.binding = new.to_string());
    })
    .render(cx, window)

Props

Method Purpose
mode(m) KeybindingInputMode::Idle (default) / Capturing.
placeholder(text) Hint shown when empty.
disabled(v) Disable interaction.
on_change(closure) Fn(&str, &mut Window, &mut App) + 'static + Send + Sync. Fired with the captured combo as a string.
on_start_capture(closure) Fn(&mut Window, &mut App) + 'static + Send + Sync. The input is now capturing.
on_cancel_capture(closure) Fn(&mut Window, &mut App) + 'static + Send + Sync. The user dismissed capture (e.g. pressed Escape).

Factory takes (id) only. .render(cx, window) returns AnyElement. The parent view typically flips mode(...) between Idle and Capturing in response to the input's on_click. The boot step from TextInput covers this component too.

See also: TextInput, ShortcutHint.

Clone this wiki locally