jsakamoto / Toolbelt.Blazor.HotKeys

This is a class library that provides configuration-centric keyboard shortcuts for your Blazor WebAssembly (client-side) apps.
https://jsakamoto.github.io/Toolbelt.Blazor.HotKeys/
Mozilla Public License 2.0
111 stars 14 forks source link

๐Ÿ’ป Support for MacOS option key #17

Closed bradystroud closed 2 years ago

bradystroud commented 2 years ago

Hi,

This would be a very similar change to 023b874

jsakamoto commented 2 years ago

Doesn't the macOS option key work as ModKeys.Alt?

I'm not sure because I don't have any macOS devices, but MDN Web Docs say it should be working as an altKey.

jsakamoto commented 2 years ago

Ah...

I found a thread in the "Stack overflow" site.

It turns out that Option+u was actually returning the character ยจ instead of u for the key attribute.

Just as a historical reason, this library's current implementation looks up the key property first before looking up the code property.

https://github.dev/jsakamoto/Toolbelt.Blazor.HotKeys/blob/cbbc1a72e670d9d58b4af2f02dcfd6f01c6a94dc/Toolbelt.Blazor.HotKeys/script.module.ts#L130-L135

I might have to rewrite the part of this library where the above link points.

(...But I don't have any macOS devices... I have to go to Apple Store first!? ๐Ÿ˜…)

bradystroud commented 2 years ago

Hi @jsakamoto,

It seems like NativeCode always shows the correct character, so yes, it looks like https://github.com/jsakamoto/Toolbelt.Blazor.HotKeys/blob/master/Toolbelt.Blazor.HotKeys/script.module.ts#L130-L134 will need to be rewritten to use code primarily ๐Ÿ˜ข

jsakamoto commented 2 years ago

@bradystroud
I fixed it at commit d803418fd9e6b7ff5516eb7700ae2a17f5acc444 !

image

(I used https://www.lambdatest.com/ to test it.)

Could you try out the latest version of the "Blazor Hotkeys" NuGet package?

bradystroud commented 2 years ago

(Closing issue) Hey @jsakamoto,

It works! ๐Ÿ™‚ Thanks for that - Much appreciated