[Discussion] Roadmap to Version 4
See original GitHub issue👋 Announcing Version 4
I am currently overhauling the docs and while writing new and extensive documentation and tutorials on the hook, I realized a lot of shortcomings that are based on the fact that I never planned this to be a popular hook.
This is why I’d like to write out a roadmap to Version 4 that should address all those issues including its own basis on registering hotkeys instead of relying on an external package.
Version 4 will target modern browsers (otherwise writing and maintaining a hotkeys handling basis would be too time consuming), so there is a chance that some users will be stuck on version 3. To minimize the pain I’d like to hear from you what some of your pain points are when using the hook (what you think is confusing, what doesn’t work as expected, what could be improved, etc), what you would like to see as new features and in which context (browser support, etc) you are using the package. Thank you all in advance 😊
🚧 Current Problems
- Handling of the
alt
modifier is complicated - There is no support for scopes #290
- The API is cluttered with inconsistencies (filter, enable seem counterintuitive)
- The
+
key is not working when using a differentsplitKey
#544 - ~You cannot use key codes~
- Doesn’t work with React Portals #405
-
enableOnTags
is not very intuitive if you don’t use TypeScript since you need to know that you have to type out the tag names in capital letters -
enableOnTags
should at least be case-insensitive. - The meaning of the return of
filter
is currently inversed. Returningfalse
prevents the callback from getting executed,true
bypasses the filter. - Exposing
hotkeys.isPressed
as a hook is unnecessary. -
isHotkeyPressed
should be able to take a combination of keys. -
onKeyDown
andonKeyUp
doesn’t trigger correctly. If the key stays down, it triggers multiple times, should only trigger once
🎯 Goals for Version 4
- All current features should be preserved
- Drop hotkeys.js package
- Only target modern browsers
- Support scoping
- Support Portals
- Clean up API
- Add a function which returns all currently pressed keys
- Add a function which returns all currently bound hotkeys
- Bind events to ref element otherwise to document
- Set up CI/CD pipeline for publishing
🏗️ Track of V4 API changes
- Merge
filter
intoenabled
- Rename
splitKey
tocombinationKey
-
splitKey
refers to the actual splitting of multiple hotkeys - Make the
options
object anddependency
array interchangable - Allow the first parameter to be an array.
- Add
scopes
option tooptions
object - Add
preventDefault
to theoptions
object - Replace
any[]
as dependency type withDependecyList
-
cmd/command
becomesmeta
-
enableOnTags
now accepts a boolean (if set totrue
, all input tags are enabled) -
enableOnTags
becomesenableOnFormTags
-
isHotkeyPressed
takes an array or string as first argument -
isHotkeyPressed
takes a splitChar as an optional second argument (defaults to,
)
🐛 Bugs
- Nested Scoping doesn’t work
- Arrow keys (
down
,left
, etc.) aren’t mapped to ArrowDown, ArrowLeft, etc.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:40
- Comments:26 (13 by maintainers)
@devinhalladay and every body else who are eager to try out the new version: A pre release is now available under either
next
or4.0.0-1
I didn’t had any time to rewrite the readme yet, so usage is visible in the tests here: https://github.com/JohannesKlauss/react-hotkeys-hook/blob/feature/version-4/tests/useHotkeys.test.tsx
Or just have a look at the source code here: https://github.com/JohannesKlauss/react-hotkeys-hook/blob/feature/version-4/src/useHotkeys.ts
Please let me know if you encounter any strange behavior and/or bugs.
Please note that there are quite some breaking changes involved, so please check the API changes above (https://github.com/JohannesKlauss/react-hotkeys-hook/issues/574#issue-951354306) first
I am also happy to say that I am nearing feature completeness (only portal functionality is missing).
If you want to use the new Scoping feature to group hotkeys together (and activate/deactivate scopes programmatically) you have to wrap your app with
<HotkeysProvider>
Hey everybody, I finally have the resources to work on version 4. So if you have any specific features in mind, wishes, improvements, etc. now is the time to let me know 😃
I can’t give a timeline yet, but I hope to release a candidate around march. If anybody has experience in writing documentation and is willing to help me out, I’d love to take it, because this is the tedious part as I learnt the last time.