timelineKeys

fun Modifier.timelineKeys(state: TimelineState, scrub: ScrubState? = null, position: () -> Duration, step: Duration = FilmstripTimelineDefaults.KeyStep, enabled: Boolean = true): Modifier(source)

Keyboard control over a timeline: arrows seek, home and end jump to the ends, and plus and minus step the zoom ladder.

Left and right seek by step, and by five times step with shift held. A held arrow repeats through ArrowScrubGesture rather than issuing a settling seek per repeat, which is what keeps the scrub relaxed for the whole burst instead of cancelling itself dozens of times a second. Zooming holds the middle of the viewport still, which is the one focal point a key press has. A null scrub leaves the seeking keys doing nothing, matching how dev.jordond.filmstrip.compose.ui.FilmstripTimeline treats a null scrub as a timeline a drag does not seek either; the zoom keys work regardless.

This makes the modified element focusable, but does not request focus itself: composing it is not enough to receive a key press. A host gives it focus the ordinary way, chaining Modifier.focusRequester ahead of this and calling requestFocus() on it from wherever the host decides the timeline should become the keyboard's target, such as a click on it. A component that took focus on composition would steal it from whatever the host had focused before.

Parameters

state

The timeline the zoom keys step.

scrub

The protocol a seek is driven through, or null for a timeline the keys do not seek.

position

Where the playhead sits, read once when an arrow burst begins so a repeat inside it advances from its own last target rather than a clock the scrub has not caught up to yet.

step

How far left and right seek. Shift multiplies it by five.

enabled

Whether the keys are read at all.