VisorVisor
Hooks

useKeyboardNav

Handles keyboard navigation for deck-style slide presentations (Arrow keys, Home, End, Space).

Usage

useKeyboardNav({
  containerRef,
  goTo,
  currentIndexRef,
  totalSectionsRef,
})

Installation

npx visor add use-keyboard-nav

Parameters

NameTypeRequiredDefaultDescription
containerRefReact.RefObject<HTMLElement | null>No--Container element to listen on. Falls back to document if not provided.
goTo(index: number) => voidYes--Navigation function that scrolls to the given section index.
currentIndexRefReact.MutableRefObject<number>Yes--Mutable ref holding the current section index.
totalSectionsRefReact.MutableRefObject<number>Yes--Mutable ref holding the total number of sections.

Returns

This hook does not return a value.