Toolbelt.Blazor.HotKeys2 icon indicating copy to clipboard operation
Toolbelt.Blazor.HotKeys2 copied to clipboard

Overriding default Browser shortcuts

Open phcd30 opened this issue 1 year ago • 2 comments

Is there a way to override the browser shortcuts, for example CTRL+S in Edge brings up the Save Dialog instead of the HotKeys configuration I've set up?

phcd30 avatar Apr 19 '24 09:04 phcd30

Hi @phcd30,

You must be able to override and prevent the default keyboard shortcuts like Ctrl+S without any specials.

However, in some cases, you need to use the HotKeys.CreateContext in the OnAfterRender lifecycle method instead of the OnInitialized lifecycle method. Otherwise, the Blazor HotKeys won't work. My README document said to use the OnInitialized, which might be why you asked such a question. Could you try using the OnAfterRender method instead of the OnInitialized method to initialize the hotkeys?

I have also attached the sample projects that override and prevent the browser's Ctrl+S keyboard shortcut. I hope these sample projects help you.

I also updated the README document to mention the use of the OnAfterRender method to initialize hotkeys.

jsakamoto avatar Apr 20 '24 02:04 jsakamoto

Yes! That seems to work, thanks!

phcd30 avatar Apr 26 '24 12:04 phcd30