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
87 stars 6 forks source link

Added a `ToKeys` method to return array of keys instead of formatting #13

Closed uhfath closed 7 months ago

uhfath commented 7 months ago

Added a helper method HotKeyEntry.ToKeys to return array of formatted keys like in ToString. This is useful if one want's to display something like this: Ctrl + Shift + A Note that each element can be a separate HTML tag (like <span> or anything else). Using ToString would require extracting text manually.

Also added a simple test for new method and retained backward compatibility for ToString (it uses ToKeys now).

jsakamoto commented 7 months ago

@uhfath Thank you for your great contributions! The ToKeys method is a nice idea that I could not come up with. Many developers will be saved this new capability of the Blazor HotKeys.

By the way, the name of this method, ToKeys, makes me feel it will return something different from the array of string. I feel like it will return some kind of object representing the concept of "key". So, do you mind if I would like to change the name of this method from ToKeys to ToKeyStrings? Please tell me what you think about this suggestion.

uhfath commented 7 months ago

@jsakamoto thanks for taking the time. Good idea regarding renaming the method. Another idea is perhaps something like ToStringKeys as analogue to ToString which returns keys. In this case when used with intelli-sense while typing the code both of them would show up near to each other.

jsakamoto commented 7 months ago

@uhfath Thank you for the reply. So, I renamed the method name from ToKeys to ToStringKeys and published it as a new version, v.3.2.1.

Thank you for your contribution!

uhfath commented 7 months ago

Happy to help. Your project is very helpful.