Introducing stimulus-shortcut

No shortcuts.

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.

 
9
Kudos
 
9
Kudos

Now read this

Mutation-first development: a call to action

Not that long ago, someone designing a JavaScript component could rely on a simple life-cycle premise: your content would load before the jQuery embedded in the bottom of the page would come to life and initialize everything that needed... Continue →