Railsdesigner iconRailsdesignerOct 1, 2026 ~1 min source read

More than click and submit: use any event with Stimulus

I recently surprised someone by showing you can use any event besides the common click, submit and keydown events. The Stimulus docs list those seven default events and their shorthand equivalents.

Share this story

Send the public story page.

Useful takeaways from this story.

I recently surprised someone by showing you can use any event besides the common click, submit and keydown events.

The data-action descriptor is event->controller#method where you can bind to anything the DOM throws at you: native element events, global document events, even custom dispatched events.

The Stimulus docs list those seven default events and their shorthand equivalents.

Building the complete brief

The page is ready to read now. The fuller skim-friendly version will appear here automatically.

The useful part

I recently surprised someone by showing you can use any event besides the common click, submit and keydown events. The Stimulus docs list those seven default events and their shorthand equivalents. The data-action descriptor is event->controller#method where you can bind to anything the DOM throws at you: native element events, global document events, even custom dispatched events.

How it works

  • I put together a small demo repo to show a handful of these in action.
  • Lets go over them and maybe you find a way to refactor and simplify one of your Stimulus controllers.

Keep reading in the app

Open the app view to save this story, compare related coverage, and continue from the same source.

Open in app