attach-dom-events

util to attach multiple dom events to an element

Usage no npm install needed!

<script type="module">
  import attachDomEvents from 'https://cdn.skypack.dev/attach-dom-events';
</script>

README

attach-dom-events

unstable

Utility to attach multiple dom events to an element. Uses dom-events.

var attach = require('attach-dom-events')

attach(element, {
    mousemove: function(ev) {
        //..
    },
    keydown: function(ev) {
        //..
    }
})

Usage

NPM

attach(element[, events])

attach.on(element[, events])

Attaches the dictionary of events to element, using the keys as event names for addEventListener.

The main exported method is the same as on.

attach.off(element[, events])

Detaches all the given events.

attach.once(element[, events])

Attaches all the given events using once instead of on.

License

MIT, see LICENSE.md for details.