Utilities
Standalone focus, navigation item, scroll locking, and key mapping utilities from @diffgazer/keys.
Standalone focus, navigation item, scroll locking, and key mapping utilities. Most work independently of KeyboardProvider; package-only utilities should be imported from @diffgazer/keys.
For the complete API reference, see the @diffgazer/keys documentation.
useFocusTrap
Traps Tab/Shift+Tab focus within a container. Works independently of KeyboardProvider.
@diffgazer/ui's DialogContent and CommandPaletteContent compose this focus-trap behavior through their shared dialog shell.
useFocusRestore
Captures the currently focused element before a temporary surface opens and restores it when that surface closes. This is used by @diffgazer/ui overlay primitives so nested dialogs and command palettes restore focus in close order.
Use this for app-owned overlays or temporary focus zones. Prefer the built-in behavior on Dialog and CommandPalette when using those primitives directly.
useScrollLock
Reference-counted scroll lock. Sets overflow: hidden on an element, restores the original value when all locks are released.
@diffgazer/ui's DialogContent and CommandPaletteContent own their background scroll lock through this hook, pointing it at the overlay's own ownerDocument.body while it is open and modal. The reference counting is what lets a stack of them hold one lock, and the hook adds the scrollbar's width to padding-right so hiding the scrollbar does not shift the page. Call it directly for app-owned overlays or custom scroll containers.
navigation item utilities
Package-mode helpers for component authors who need the same DOM item discovery contract used by useNavigation, NavigationList, RadioGroup, and related primitives.
Use getNavigationItemProps(type, value) instead of inventing a local selector contract. It writes data-diffgazer-navigation-item and data-value, which keeps app-built primitives compatible with the same focus and navigation logic as the registry components.
keys()
Utility to map multiple hotkeys to the same handler. Requires the full @diffgazer/keys package (not available in copy mode).