hotwired / stimulus

A modest JavaScript framework for the HTML you already have
https://stimulus.hotwired.dev/
MIT License
12.73k stars 426 forks source link

Support multiple keystroke binds for KeyboardEvent Filter #776

Open omarluq opened 5 months ago

omarluq commented 5 months ago

Hello,

I'm aware that there was a previous conversation around multi-event actions support which was rejected, but I think there is a strong argument to be made for multiple keystrokes support with KeyboardEvent Filter. More often than not, you have multiple keys that need to trigger the same action.

Currently

<button
  data-controller='my-controller' 
  data-action='keydown.delete->my-controller#my-action:prevent 
               keydown.backspace->my-controller#my-action:prevent' />

proposed

<button
  data-controller='my-controller' 
  data-action='keydown.(delete, backspace)->my-controller#my-action:prevent />

I believe this change would significantly improve developer experience when working with keyboard events in Stimulus.