DEV Community

Cover image for Introducing stimulus-shortcut
leastbad
leastbad

Posted on

Introducing stimulus-shortcut

Hot on the heels of stimulus-hotkeys, I am thrilled to release stimulus-shortcut, "a Stimulus controller for mapping keystrokes to element events".

Based on the preview version of Stimulus 2.0, stimulus-hotkeys wraps the amazing HotKeys.js library and takes advantage of the new Stimulus Values API to bind the keystrokes people type to the default events of elements on your page.

Let's look at a simple example, in which the user hits the "p" key and it makes the link click itself.

<a data-controller="shortcut" data-shortcut-key-value="p">Type 'p' to activate me!</a>

It's a sort of sister-controller to stimulus-hotkeys in that they share dependencies and together, cover both common shortcut key patterns. They can be used happily together in the same project.

That's about it! You can learn more on the Github project page.

Top comments (4)

Collapse
 
briankephart profile image
Brian Kephart

I keep seeing reference to upcoming versions of Stimulus and Turbolinks, but the GitHub repos don't show anything. Is this information publicly available somewhere?

Collapse
 
leastbad profile image
leastbad

The polite version is that we just don't know. The way Stimulus and Turbolinks are developed is open source in name only. There's a chance that now Hey.com email is released, they might pick up the pace and start engaging with their developer community again. We are promised new releases "soon" - and I think they mean it, without wanting to commit to a date. I think that they believe mystery and promotion are interchangeable, but in reality it's just pissing people off.

I started a forum post that received a lot of upvotes but there was a loud absence of anyone from Basecamp chiming in. It's on track to receive 50 upvotes - maybe you can help? discuss.rubyonrails.org/t/turbolin...

Anyhow, the short version is that the libraries are both great, very much alive and under active development that we're just not allowed to see. Meanwhile, the community around these tools is growing by leaps and bounds.

You can find the URL for the Stimulus 2.0 preview package here: github.com/stimulusjs/stimulus/pul... and the Turbolinks 6 build I'm using is hacked together from the Hey.com source code, and frankly there's not a good reason to be using it over v5 until Rails 6.1 comes out, hopefully with a lot more server-side interaction with the new functionality. Until then, I'd focus my attentions on using StimulusReflex and CableReady, if you're a Rails developer.

Collapse
 
briankephart profile image
Brian Kephart

I saw your post on the forum back at the time, and I agree with all of it. There is an unnecessary amount of uncertainty surrounding Stimulus and Turbolinks.

Thread Thread
 
leastbad profile image
leastbad

What's genuinely frustrating is that the ecosystem and community around the libraries has never been stronger.

Consider this to be a pointed invitation to join the StimulusReflex Discord and check out the #stimulus channel. All of the conversation not happening on the Stimulus Discourse forum is happening there. discord.gg/XveN625