github / hotkey

Trigger an action on an element with a keyboard shortcut.
https://github.github.com/hotkey/
MIT License
3.22k stars 97 forks source link

fixes `eventToHotkeyString` returns doubled "modifier" when "key" is a modifier #64

Closed theinterned closed 2 years ago

theinterned commented 2 years ago

resolves #60

This PR fixes a bug where eventToHotkeyString was returning a "double modifier" for a key-combination where a modifier key (Control, Alt, Meta, or Shift) is also the event.key.

This PR updates eventToHotkeyString so that the resulting string still presents modifiers in a consistent order.

For more details see #60

Before After
Screen Shot 2021-12-15 at 9 50 36 AM Screen Shot 2021-12-16 at 5 58 21 PM

Screencast of the after

https://user-images.githubusercontent.com/2694/146461487-c3832946-788c-47be-a3f3-eadfe712a5e7.mov

Breaking change

Although the previous behaviour was likely a bug, this is a breaking change in that it changes the "hotkey string" format when a modifier key is used as the hotkey (the final element in a hotkey string sequence) for example Meta+Shift+Shift becomes Meta+Shift after this change.

theinterned commented 2 years ago

I wonder if you reviewers would consider this a breaking change? It is arguably as the format of the string does change.