packages/material-ui-lab/src/internal/pickers/hooks/useKeyDown.ts/useKeyDownHandler
export function useKeyDownHandler(active: boolean, keyHandlers: KeyHandlers) {
  const keyHandlersRef = React.useRef(keyHandlers);
  keyHandlersRef.current = keyHandlers;

  return React.useCallback(
    (event: React.KeyboardEvent) => {
      if (active) {
        runKeyHandler(event, keyHandlersRef.current);
      }
    },
    [active],
  );
}