Toolbelt.Blazor.HotKeys
Toolbelt.Blazor.HotKeys copied to clipboard
Feature Request: key binding for specific element
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 Thank you for your proposal!
Your idea is interesting to me. I'll consider implementing this feature.
Are there any plans to implement this functionality?
@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!