Stimulus V3.2.2 Adds Declarative Key Event Handling
Stimulus v3.2.2 introduces declarative syntax for handling key events with data-action attribute, allowing cleaner & more readable code.
What it was In the last update of Stimulus v3.2.2, the ability to filter the event by PageDown and PageUp keys was added. Before that, in v3.2.1, it looked like this: <div data-action="keyup->myController#myfunction"></div> and some like this... import { Controller } from "stimulus"; export default class extends Controller { connect() { // Add a keydown event listener when the controller is connected to the DOM document.addEventListener("keydown", this.handleKeyDown); } disconnect() { // Remove the keydown event listener when the controller is dis...