jsakamoto / Toolbelt.Blazor.HotKeys2

This is a class library that provides configuration-centric keyboard shortcuts for your Blazor apps.
https://jsakamoto.github.io/Toolbelt.Blazor.HotKeys2/
Mozilla Public License 2.0
103 stars 7 forks source link

Can we include "colon" in the Code? #9

Closed TFujisawa123 closed 1 year ago

TFujisawa123 commented 1 year ago

Code.List.cs contains a semicolon but no colon. It would be great if a colon could be added.

jsakamoto commented 1 year ago

@TFujisawa123 That's by design. A colon should be defined as a Key, not a Code. Surprisingly, when a Japanese user types the : key on a Japanese layout keyboard, the keyboard event argument will represent "Quote" as a code.

image

On the other hand, when a US user types the : key on a US-English layout keyboard, it will be "Shift" + "Semicolon" as a code.

image

As you will understand from that example, we cannot handle the : key down event stably among various keyboard layouts in the world if we use a Code to identify the key. Therefore, if you need to identify the : key down event, you should use Key Instead of Code. The event argument of the : key down event will always represent the ":" as a Key. Of course, the Key class has a Colon static property.

https://github.com/jsakamoto/Toolbelt.Blazor.HotKeys2/blob/1277e6114d7486ea072e6e90b41849979f01ccab/HotKeys2/Key.List.cs#L345

Please see also the "Code vs. Key - which way should I use to?" section in the README.