React hook for using keyboard shortcuts in components.
MIT License
Bot releases are visible (Hide)
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.
<HotkeysProvider>
enabledScopes
in the HotkeysProvider
has been renamed to activeScopes
HotkeysProvider
no hotkeys will be activeuseHotkeys
splitKey
option has been renamed to delimiter
combinationKey
option has been renamed to delimiter
useKey
: Setting this to true will listen to the produced key rather than the code. Helpful if you want to listen to something like ?
, +
, !
...control
instead of ctrl
wouldn't trigger correctlysplitKey
option, rename that to delimiter
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
Published by JohannesKlauss 9 months ago
Full Changelog: https://github.com/JohannesKlauss/react-hotkeys-hook/compare/v4.4.4...v4.5.0
Published by JohannesKlauss 9 months ago
Full Changelog: https://github.com/JohannesKlauss/react-hotkeys-hook/compare/v4.4.3...v4.4.4
Published by JohannesKlauss 10 months ago
Full Changelog: https://github.com/JohannesKlauss/react-hotkeys-hook/compare/v4.4.2...v4.4.3
Published by JohannesKlauss 10 months ago
Full Changelog: https://github.com/JohannesKlauss/react-hotkeys-hook/compare/v4.4.1...v4.4.2
Published by JohannesKlauss over 1 year ago
Full Changelog: https://github.com/JohannesKlauss/react-hotkeys-hook/compare/v4.4.0...v4.4.1
Published by JohannesKlauss over 1 year ago
Full Changelog: https://github.com/JohannesKlauss/react-hotkeys-hook/compare/v4.3.8...v4.4.0
Published by JohannesKlauss over 1 year ago
Full Changelog: https://github.com/JohannesKlauss/react-hotkeys-hook/compare/v4.3.7...v4.3.8
Published by JohannesKlauss over 1 year ago
Full Changelog: https://github.com/JohannesKlauss/react-hotkeys-hook/compare/v4.3.6...v4.3.7
Published by JohannesKlauss over 1 year ago
Full Changelog: https://github.com/JohannesKlauss/react-hotkeys-hook/compare/v4.3.5...v4.3.6
Published by JohannesKlauss over 1 year ago
Full Changelog: https://github.com/JohannesKlauss/react-hotkeys-hook/compare/v4.3.4...v4.3.5
Published by JohannesKlauss over 1 year ago
Full Changelog: https://github.com/JohannesKlauss/react-hotkeys-hook/compare/v4.3.3...v4.3.4
Published by JohannesKlauss over 1 year ago
Full Changelog: https://github.com/JohannesKlauss/react-hotkeys-hook/compare/v4.3.2...v4.3.3
Published by JohannesKlauss almost 2 years ago
Full Changelog: https://github.com/JohannesKlauss/react-hotkeys-hook/compare/v4.3.1...v4.3.2
Published by JohannesKlauss almost 2 years ago
Full Changelog: https://github.com/JohannesKlauss/react-hotkeys-hook/compare/v4.3.0...v4.3.1
Published by JohannesKlauss almost 2 years ago
Full Changelog: https://github.com/JohannesKlauss/react-hotkeys-hook/compare/v4.2.1...v4.3.0
Published by JohannesKlauss almost 2 years ago
Full Changelog: https://github.com/JohannesKlauss/react-hotkeys-hook/compare/v4.2.0...v4.2.1
Published by JohannesKlauss almost 2 years ago
useRecordHotkeys
by @JohannesKlauss in https://github.com/JohannesKlauss/react-hotkeys-hook/pull/881
Full Changelog: https://github.com/JohannesKlauss/react-hotkeys-hook/compare/v4.1.1...v4.2.0
Published by JohannesKlauss almost 2 years ago
Full Changelog: https://github.com/JohannesKlauss/react-hotkeys-hook/compare/v4.1.0...v4.1.1
Published by JohannesKlauss almost 2 years ago
Full Changelog: https://github.com/JohannesKlauss/react-hotkeys-hook/compare/v4.0.8...v4.1.0