Stencil keydown event listener is not working when it is in an NPM package

314 Views Asked by At

I am using Stencil2+ in my application. I have one query related to the keydown event of Stencil. When I use the keydown event directly from the component, the listener is able to react to the event. But when I am using my component inside another component as an NPM package, the listener is not able to react on the event. I have tried to use the target option as document, but the document option is targeting the document of my main application not the NPM package application.

@Listen('keydown', { passive: true })
private keyListener(ev: KeyboardEvent) {
   if (ev.key === 'Escape') {
     this.hide()
   }
}

Let me know if anybody has faced this issue in their application and if anybody have any solution for it.

0

There are 0 best solutions below