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

Is it possible to disable keyboard shortcuts for contenteditable div?

Open k2tomasz opened this issue 4 years ago • 2 comments

Hot to disable shortcuts for contenteditable ?

k2tomasz avatar Nov 11 '21 20:11 k2tomasz

Unfortunately, it is impossible to disable keyboard shortcuts for contenteditable div at this time.

Actually, I designed this library as a clone of the "angular-hotkeys" library, so I did not consider numerous situations well.

I may have to extend the "AllowIn" feature, like adding a new "AllowIn.NonContentEditable" flag to resolve this problem.

I'll consider that do or do not it.

jsakamoto avatar Nov 12 '21 13:11 jsakamoto

I released "Toolbelt.Blazor.HotKeys" ver.12.0.0 today.

  • https://www.nuget.org/packages/Toolbelt.Blazor.HotKeys/12.0.0

I added the "Exclude" flags for this version, and I deprecated the "AllowIn" flags instead.

So if you want to disable a hotkey for any "contenteditable" elements, then you can do that with the code like this:

this.HotKeysContext = this.HotKeys.CreateContext()
  .Add(ModKeys.None, Keys.A, OnKeyDownA, "...", Exclude.Default | Exclude.ContentEditable)
  ...

Could you try it out?

jsakamoto avatar Nov 14 '21 12:11 jsakamoto