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

Include `Shift` key with uppercase letter hotkeys #115

Closed iansan5653 closed 11 months ago

iansan5653 commented 11 months ago

Currently we only include the Shift key in the hotkey string if the user is not typing a letter. This is inconsistent: for any other modifier, we always include it in the string if held. But for Shift, we only sometimes include it in the string if held.

To make hotkey strings easier to reason with, this PR changes the logic to always include Shift if held.

[!IMPORTANT] This is a breaking change we should release with a major version bump (3.0.0). Any existing hotkeys that use uppercase letters without Shift will need to be updated to add Shift. So A would become Shift+A, B would become Shift+B, etc. This does mean that these hotkeys will no longer fire if the letter is pressed alone when CapsLock is on. I think this is acceptable because this behavior was never clearly defined in the docs and it is unintuitive that different effects might occur depending on whether caps lock is on or not.

This closes https://github.com/github/hotkey/issues/54 by making Shift handling consistent across all keys and platforms.