Skip to content

Disable keyboard navigation #319

Answered by igordanchenko
Arillaxe4 asked this question in Q&A
Discussion options

You must be logged in to vote

There is no setting for this, but you can implement it with a custom plugin.

function DisableKeyboardNavigation({ children }: ComponentProps) {
  const { subscribeSensors } = useController();

  React.useEffect(
    () =>
      subscribeSensors(EVENT_ON_KEY_DOWN, (event) => {
        if (event.key === VK_ARROW_LEFT || event.key === VK_ARROW_RIGHT) {
          event.stopPropagation();
        }
      }),
    [subscribeSensors],
  );

  return children;
}

// ...

<Lightbox
  // ...
  plugins={[({ addModule }) => addModule(createModule("DisableKeyboardNavigation", DisableKeyboardNavigation))]}
/>

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Arillaxe4
Comment options

Answer selected by Arillaxe4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants