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

Feature Request: key binding for specific element

Open Liero opened this issue 3 years ago • 3 comments

As far as I know, it is only possible to create global binding.

However I would like to create key binding valid any for specific element / component.

I think Angular2-Hotkeys solves this by having context per component instance. The library then listens to keys on HTML representing the component.

However, Blazor components does not create any html wrapper elements like angular.

Proposal:

The CreateContext() method could take an ElementReference or css selector as a parameter:


<div @ref="myElement">
</div>

@code {

ElementReference? _myElement;

protected override void OnAfterRender(bool firstRender)
{
    base.OnAfterRender(firstRender);
    if (firstRender) 
    {
       _hotKeysContext = this.HotKeys.CreateContext(_myElement)
                .Add(...)
    }
}

}

If #18 would be implemented, it could take parent element.

Liero avatar Dec 02 '21 13:12 Liero

@Liero Thank you for your proposal!

Your idea is interesting to me. I'll consider implementing this feature.

jsakamoto avatar Dec 03 '21 11:12 jsakamoto

Are there any plans to implement this functionality?

NUlliiON avatar Jul 03 '22 18:07 NUlliiON

@NUlliiON Thank you for your comment!

I already have an idea to implement this feature proposal, but unfortunately, I've not been able to get started yet... though after six months since this issue was posted.

I'll keep trying to make time to do that!

jsakamoto avatar Jul 04 '22 12:07 jsakamoto