Skip to content

Toggling works with useEffect but doesn't work with useHotKeys #704

Discussion options

You must be logged in to vote

That is because the input in your popup is receiving focus when it gets displays. Keyboard events are ignored in useHotkeys unless you define the form tags you want it to listen to. If you enable hotkeys for input tags it works fine:

useHotkeys(
  "command+k, ctrl+k",
  () => {
    state.toggleCommandPalette();
  },
  {
    enableOnTags: ["INPUT"]
  }
);

Codesanbox: https://codesandbox.io/s/combobox-bug-forked-6rdzqh

Replies: 1 comment 1 reply

Comment options

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

Answer selected by deadcoder0904
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