trigger-event

1.0.5 • Public • Published

trigger-event

Programmatically trigger a DOM event.

Rewrite of ianstormtaylor/trigger-event for npm+browserify support.

Example

var triggerEvent = require('trigger-event');

triggerEvent(document, 'keydown', {key: 'enter'});
triggerEvent('keydown', {key: 'enter'})

Installation

$ npm install trigger-event

API

var triggerEvent = require('trigger-event');

triggerEvent([element, ]type[, options])

Programmatically triggers a DOM event of type:

  • 'click'
  • 'dblclick'
  • 'keydown'
  • 'keyup'

document is used if element is not provided.

Default options:

{
  alt: false,
  bubbles: true,
  button: 0,
  cancelable: true,
  clientX: 0,
  clientY: 0,
  ctrl: false,
  detail: 1,
  key: 0,
  meta: false,
  relatedTarget: null,
  screenX: 0,
  screenY: 0,
  shift: false,
  view: window
}

Package Sidebar

Install

npm i trigger-event

Weekly Downloads

309

Version

1.0.5

License

MIT

Unpacked Size

3.76 kB

Total Files

4

Last publish

Collaborators

  • kenan