Skip to content

How to disable ESC key in ListBox #2268

Answered by LFDanLu
dimitrisnl asked this question in Q&A
Discussion options

You must be logged in to vote

You can override the onKeyDown returned by useListBox so that it early returns on Escape:

  let onKeyDown = (e) => {
    if (e.key === "Escape") {
      return;
    }

    listBoxProps.onKeyDown(e);
  };

See https://codesandbox.io/s/trusting-perlman-p0e5p?file=/src/App.js:557-670 for a rough example.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by dimitrisnl
Comment options

You must be logged in to vote
0 replies
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