JohannesKlauss / react-hotkeys-hook

React hook for using keyboard shortcuts in components.
https://react-hotkeys-hook.vercel.app/
MIT License
2.71k stars 114 forks source link

[QUESTION] - Keys doesn't include modifiers? #1070

Open stwilz opened 1 year ago

stwilz commented 1 year ago

Hi! Just migrated from v3 to v4 and noticed that our returned keys doesn't include modifiers?

Previously we did these ones.

  const HOTKEYS = [
    {
      keys: 'ctrl+alt+s',
      type: 'save',
    },
    {
      keys: 'ctrl+alt+f',
      type: 'find',
    },
  ]

  useHotkeys(
    HOTKEYS.map(hotkey => hotkey.keys).join(','),
    (_, { key }) =>
      setActive(HOTKEYS.find(({ keys }) => keys === key)?.type || null)
  )

Which was pretty straight forward but now we've needed to put in some extra smarts to match the callbacks. Is not including the modifiers the expected behavior?

PS Great work on the library!

JohannesKlauss commented 11 months ago

Ah yes, this is a design issue that will be fixed in version 5. Thank you for reporting this