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

My first npm package: stimulus-image-grid

A Stimulus controller for beautiful image grids # I published my first npm package today! https://www.npmjs.com/package/stimulus-image-grid With only three optional parameters, this is a simple, drop-in, backend-agnostic, code-free... Continue →