Skip to main content

move_slider_on_keys

Function move_slider_on_keys 

Source
pub fn move_slider_on_keys(
    keys: MessageReader<'_, '_, KeyPressed>,
    tracker: Res<'_, FocusTracker>,
    sliders: Query<'_, '_, &mut SliderValue>,
    out: MessageWriter<'_, SliderChanged>,
)
Expand description

Keyboard control for a focused <slider>. Reads the raw KeyPressed bus directly rather than FocusedKey - the same pattern lumen_primitives::tabs::dispatch_tab_keys uses for its roving-tabindex nav - since a slider isn’t a TextInput and doesn’t need the extra dispatch_focused_keys routing hop.

  • ArrowLeft / ArrowDown: decrement by one step.
  • ArrowRight / ArrowUp: increment by one step.
  • PageDown / PageUp (forwarded by the winit backend as Key::Character("PageDown"/"PageUp") - there’s no dedicated NamedKey variant for them yet): move by ten steps.
  • Home / End: jump to min / max.

Step comes from SliderValue::step_size: the authored step attribute, or (max - min) / 100 - matching the <input type=range> browser default of 100 discrete positions.