gridNavigation static method

KeyBindings gridNavigation({
  1. required void onUp(),
  2. required void onDown(),
  3. required void onLeft(),
  4. required void onRight(),
  5. String hintLabel = '↑/↓/←/→',
  6. String hintDescription = 'navigate',
})

Creates 2D grid navigation bindings with custom move functions.

Used for grid-based selection (GridSelect, ChoiceMap) where navigation wraps around edges and needs custom logic.

Implementation

static KeyBindings gridNavigation({
  required void Function() onUp,
  required void Function() onDown,
  required void Function() onLeft,
  required void Function() onRight,
  String hintLabel = '↑/↓/←/→',
  String hintDescription = 'navigate',
}) {
  return KeyBindings([
    KeyBinding.single(KeyEventType.arrowUp, (event) {
      onUp();
      return KeyActionResult.handled;
    }),
    KeyBinding.single(KeyEventType.arrowDown, (event) {
      onDown();
      return KeyActionResult.handled;
    }),
    KeyBinding.single(KeyEventType.arrowLeft, (event) {
      onLeft();
      return KeyActionResult.handled;
    }),
    KeyBinding.single(
      KeyEventType.arrowRight,
      (event) {
        onRight();
        return KeyActionResult.handled;
      },
      hintLabel: hintLabel,
      hintDescription: hintDescription,
    ),
  ]);
}