jQuery’s event system normalizes the event object according to W3C standards<. The event object is guaranteed to be passed to the event handler. Most properties from the original event are copied over and normalized to the new event object.
jQuery.Event Constructor
The jQuery.Event constructor is exposed and can be used when calling trigger. The new operator is optional.
Check trigger‘s documentation to see how to combine it with your own event object.
Example:
1
2
3
4
5
//Create a new jQuery.Event object without the "new" operator.
var e = jQuery.Event( "click" );
// trigger an artificial click event
jQuery( "body" ).trigger( e );
As of jQuery 1.6, you can also pass an object to jQuery.Event() and its properties will be set on the newly created Event object.
Example:
1
2
3
4
5
// Create a new jQuery.Event object with specified event properties.
var e = jQuery.Event( "keydown", { keyCode: 64 } );
// trigger an artificial keydown event with keyCode 64
jQuery( "body" ).trigger( e );
Common Event Properties
jQuery normalizes the following properties for cross-browser consistency:
target
relatedTarget
pageX
pageY
which
metaKey
The following properties are also copied to the event object, though some of their values may be undefined depending on the event: