-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I want key modifiers for keyboard events. #440
Comments
Hey @NakajimaTakuya I think the library |
@marcoroth |
stimulus-hotkeys is a really great experiment! |
@NakajimaTakuya I appreciate you spending some time going through All libraries are opinionated. While it's true that my opinions and your opinions may differ for legitimate reasons, it's also possible that I have thought about this problem longer than most people. For example, this isn't even my only Stimulus-based hotkeys library: https://github.com/leastbad/stimulus-shortcut The main reason Stimulus Hotkeys works the way that it does is because it affords complete flexibility and dynamism: you can push an update to the key bindings from the server and it will take effect immediately. Stimulus Hotkeys doesn't "control" events, but it does launch methods on controllers. That's an important distinction. This is a powerful tool and it might be too much for what you're trying to do. Feel free to borrow as much of my code as you can, because you will save yourself a lot of time and learn Stimulus better in the process. |
@leastbad Thanks for the reply. The library you suggested does indeed work and seems to meet the requirements. Maybe my first message seemed a bit urgent. I will try to submit my expected behavior as PR for more specific discussion. I am fortunate to have heard your views. |
Let me know if you have any questions whatsoever, friend. One other path that you might investigate is the https://stimulus-use.github.io/stimulus-use/#/use-hotkeys I think this is a really slick implementation that will serve many use cases. |
Thank you, I am very happy to know the different approaches. |
There are many times when we want to support keyboard operations as part of accessibility.
In such cases, you may want to include a filtering process in your code so that it only works with certain keys, as shown below.
This is redundant and can easily lead to deviations from the function name.
(It is tempting to disobey the teachings of Stimulus and name the function onKeydown().)
In particular,
ArrowDown/ArrowUp/ArrowLeft/ArrowRight/Enter/Space/Escape/Home/End
are frequently used keys.I think it would be ideal if we could use
data-action="keydown.left->tabs#switchLeft"
like in some libraries.Is there any consideration to implement such a modifier?
The text was updated successfully, but these errors were encountered: