lit-document-event

0.0.1 • Public • Published

LitDocumentEvent

Simple global event handling

Easily add listeners to the document object, and have them removed when the component disconnects.

Installation

npm install lit-document-event

Usage

<document-event eventname="keydown" @event=${this.handleKeyDown}></document-event>

It doesn't matter where in your template you put this component. It doesn't have a UI, it just adds a listener for the desired event and emits an event on the component, so you can easily bind to it with lit-html (with the @event=${this.myEventHandler} syntax). When the component is disconnected, the listener will be removed.

Demo app

To see it working, check out the demo app.

Also see

  • LitStyle - Shared component styles for LitElement
  • LitState - Simple shared app state management for LitElement

Package Sidebar

Install

npm i lit-document-event

Weekly Downloads

8

Version

0.0.1

License

LGPL-3.0-or-later

Unpacked Size

157 MB

Total Files

31

Last publish

Collaborators

  • gitaarik