Skip to content

Releases: JohannesKlauss/react-hotkeys-hook

v5.2.4

02 Feb 14:40

Choose a tag to compare

  • Merge pull request #1312 from JohannesKlauss/revert-1275-main 1197daf
  • Revert Regression introduced in "Try to prevent events firing incorrectly when using useKey: true" 612e549
  • Merge pull request #1311 from ShrimpCryptid/feat/clarify-ishotkeypressed-multiple-key-behavior 0219c01
  • doc: Updated wording on isHotkeyPressed key argument 9203b7f
  • fix: Update documentation for isHotkeyPressed to describe arguments correctly 154eab9

v5.2.3...v5.2.4

v5.2.3

14 Jan 16:48

Choose a tag to compare

What's Changed

  • chore(deps): update dependency vite to v7.1.11 [security] by @renovate[bot] in #1296
  • feat: add metadata support for hotkeys by @pkulcsarnr in #1299
  • chore(deps): update dependency vitest to v4 by @renovate[bot] in #1307
  • chore(deps): update actions/setup-node action to v6 by @renovate[bot] in #1306
  • chore(deps): update actions/checkout action to v6 by @renovate[bot] in #1305
  • fix(deps): update all non-major dependencies by @renovate[bot] in #1304
  • Try to prevent events firing incorrectly when using useKey: true by @matiastucci in #1275

New Contributors

Full Changelog: v5.2.1...v5.2.3

v5.2.1

14 Oct 08:06

Choose a tag to compare


Full Changelog: v5.2.0...v5.2.1

v5.2.0

13 Oct 08:01

Choose a tag to compare

v5.1.0...v5.2.0

What's Changed

New Contributors

Full Changelog: v5.1.0...v5.2.0

v5.1.0

14 May 11:35

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v5.0.2...v5.1.0

v5.0.0

09 Apr 16:15

Choose a tag to compare

🎉 Version 5!

Most users should not need to do any migration, but for those who use special characters (+,-/$? and so on) or a different delimiter key than + there is a bit of work to do.

🚨 Breaking Changes

<HotkeysProvider>

  • enabledScopes in the HotkeysProvider has been renamed to activeScopes
  • If all scopes are disabled in the HotkeysProvider no hotkeys will be active

useHotkeys

  • The hook now only listens to the code of the hotkey, not the produced key. This will get rid of all the confusion between different keyboard layouts, multiple accidental triggers and so on.
  • Special character mappings to the german keyboard layout code have been removed
  • The splitKey option has been renamed to delimiter
  • The combinationKey option has been renamed to splitKey
  • New Option useKey: Setting this to true will listen to the produced key rather than the code. Helpful if you want to listen to something like ?, +, !...

🐛 Bugfixes

  • Fixed a bug where listening to control instead of ctrl wouldn't trigger correctly

Migration Guide

  • If you are using the splitKey option, rename that to delimiter
  • If you are using the combinationKey option, rename that to splitKey

If you are listening to special characters like shift+1 in order to listen for the exclamation mark, rewrite your hook like so:

useHotkeys('!', callback, {useKey: true})

This will listen to the produced key instead of the code. Listening for shift is not necessary anymore, because the hook will only check if the produced key matches !, no matter how it has been produced. This will be layout agnostic.

If you want to listen to specifically shift+1, then use the hotkey like this:

useHotkeys('shift+1', callback)

useKey defaults to false, so you only need to set it, if you want to listen to special characters.

One common use case for this is listening to y and z. On a german layout those keys are swapped. So to comply with every possible keyboard layout, you would set useKey: true to listen to the produced key.

useHotkeys('y', callback, {useKey: true}) // Triggers if the user hits their y key on the keyboard depending on the layout
useHotkeys('y', callback) // Triggers if the user hits the y key implying US keyboard layout

New Contributors

Full Changelog: v4.6.2...v5.0.0

v4.6.2

09 Apr 10:13

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v4.6.1...v4.6.2

v4.6.1

02 Nov 09:54

Choose a tag to compare

What's Changed

  • Consider custom element when checking if event is by @HJK181 in #1164
  • Bump http-proxy-middleware from 2.0.6 to 2.0.7 in /documentation by @dependabot in #1217
  • Bump express from 4.19.2 to 4.21.0 in /documentation by @dependabot in #1210

New Contributors

Full Changelog: v4.6.0...v4.6.1

v4.6.0

02 Nov 09:45

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v4.5.1...v4.6.0

v4.5.1

02 Sep 09:58

Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v4.5.0...v4.5.1