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

Introducing jquery-events-to-dom-events (and jboo)

Did you know that jQuery events aren’t events? It’s true - and it’ll really mess up your night if you need to capture events from legacy jQuery components. Looking at you, hidden.bs.modal. I needed a way to make... Continue →