Skip to content

WhichKey

Wraps child and, once the user presses a leader key (Space, Ctrl+X) and the dispatcher is holding for the next step, shows a popup listing the available continuations — f Find file, b Buffers.

Learn more: Key handling

Import: package:fleury/fleury.dart, or package:fleury/fleury_core.dart in browser code.

KeyBindings(
bindings: <KeyBinding>[
KeyBinding(KeySequence.space.f, label: 'Find file', onTrigger: (_) => findFile()),
KeyBinding(KeySequence.space.b, label: 'Buffers', onTrigger: (_) => buffers()),
KeyBinding(KeySequence.space.g, label: 'Git', onTrigger: (_) => git()),
],
child: WhichKey(
child: Focus(autofocus: true, child: editor),
),
)

The popup appears only after showDelay of a sequence staying pending, so a fast completion (a vim dd in ~80 ms) never flashes it. It reads KeyBindings.pendingOf, so it updates as the sequence advances and vanishes the moment it completes, cancels, or times out.

Only completions whose binding carries a KeyBinding.label are listed; an unlabeled binding still fires but isn’t advertised. Unlike KeyHintBar, the popup lists a labeled binding even when it sets hideFromHintBar. For a custom layout, read KeyBindings.pendingOf directly instead of using this widget.

ParameterTypeDefaultDescription
child:WidgetrequiredThe app (or subtree) the popup overlays. It shows through unchanged until a key sequence is pending, then the popup floats above it.
showDelay:Durationconst Duration(milliseconds: 150)How long a sequence must stay pending before the popup appears. Keeps fast sequences from flashing it.
maxCompletions:int12Cap on how many completions the popup lists before collapsing the rest into a trailing +N more, so a leader with many bindings doesn’t produce a very tall popup. The cap is a count, not the screen height; lower it for short terminals.

WhichKey is defined in packages/fleury/lib/src/catalog/which_key.dart.

Category: Input handling & focus · All widgets