Overview of event object properties
| JavaScript
Introduction
Whenever an event occurs (eng. event), javascript places all relevant data related to the event in an “event object”, e.g. where was the mouse pointer, which button was clicked, which element was clicked… This object is always passed to the callback function, and therefore the callback function has access to all the data stored in it. We access the data through the property of the event object. All properties of the Event object are gathered in this article.
Main properties of the event object
| Object property |
Object Property |
Description |
HOME |
| bubbles |
Returns whether or not a specific event is a bubbling event |
2 |
| cancelable |
Returns whether or not an event can have its default action prevented |
2 |
| currentTarget |
Returns the element whose event listeners triggered the event |
2 |
| defaultPrevented |
Returns whether or not the preventDefault() method was called for the event |
3 |
| eventPhase |
Returns which phase of the event flow is currently being evaluated |
2 |
| isTrusted |
Returns whether or not an event is trusted |
3 |
| target |
Returns the element that triggered the event |
2 |
| timeStamp |
Returns the time (in milliseconds relative to the epoch) at which the event was created |
2 |
| type |
Returns the name of the event |
2 |
| view |
Returns a reference to the Window object where the event occurred |
2 |
Properties related to working with the mouse
| Object Property |
Description |
HOME |
| altKey |
Returns whether the “ALT” key was pressed when the mouse event was triggered |
2 |
| button |
Returns which mouse button was pressed when the mouse event was triggered |
2 |
| buttons |
Returns which mouse buttons were pressed when the mouse event was triggered |
3 |
| clientX |
Returns the horizontal coordinate of the mouse pointer, relative to the current window, when the
mouse event was triggered
|
2 |
| clientY |
Returns the vertical coordinate of the mouse pointer, relative to the current window, when the
mouse event was triggered
|
2 |
| ctrlKey |
Returns whether the “CTRL” key was pressed when the mouse event was triggered |
2 |
| detail |
Returns a number that indicates how many times the mouse was clicked |
2 |
| metaKey |
Returns whether the “META” key was pressed when an event was triggered |
2 |
| relatedTarget |
Returns the element related to the element that triggered the mouse event |
2 |
| screenX |
Returns the horizontal coordinate of the mouse pointer, relative to the screen, when an event was
triggered
|
2 |
| screenY |
Returns the vertical coordinate of the mouse pointer, relative to the screen, when an event was
triggered
|
2 |
| shiftKey |
Returns whether the “SHIFT” key was pressed when an event was triggered |
2 |
| which |
Returns which mouse button was pressed when the mouse event was triggered |
2 |
Properties related to working with the keyboard
| Object Property |
Description |
HOME |
| altKey |
Returns whether the “ALT” key was pressed when the key event was triggered |
2 |
| ctrlKey |
Returns whether the “CTRL” key was pressed when the key event was triggered |
2 |
| charCode |
Returns the Unicode character code of the key that triggered the onkeypress event |
2 |
| key |
Returns the key value of the key represented by the event |
3 |
| keyCode |
Returns the Unicode character code of the key that triggered the onkeypress event, or the Unicode
key code of the key that triggered the onkeydown or onkeyup event
|
2 |
| location |
Returns the location of a key on the keyboard or device |
3 |
| metaKey |
Returns whether the “meta” key was pressed when the key event was triggered |
2 |
| shiftKey |
Returns whether the “SHIFT” key was pressed when the key event was triggered |
2 |
| which |
Returns the Unicode character code of the key that triggered the onkeypress event, or the Unicode
key code of the key that triggered the onkeydown or onkeyup event
|
2 |
Property related to focus change
| Evernt object property |
Property description |
HOME |
| relatedTarget |
Returns the element related to the element that triggered the event |
3 |
Animation related properties
| Evernt object property |
Property description |
HOME |
| animationName |
Returns the name of the animation |
|
| elapsedTime |
Returns the number of seconds an animation has been running |
|
Properties related to transition
| Evernt object property |
Property description |
HOME |
| propertyName |
Returns the name of the CSS property associated with the transition |
|
| elapsedTime |
Returns the number of seconds a transition has been running |
|
Properties related to scroll
| Evernt object property |
Property description |
HOME |
| deltaX |
Returns the horizontal scroll amount of a mouse wheel (x-axis) |
3 |
| deltaY |
Returns the vertical scroll amount of a mouse wheel (y-axis) |
3 |
| deltaZ |
Returns the scroll amount of a mouse wheel for the z-axis |
3 |
| deltaMode |
Returns a number that represents the unit of measurements for delta values (pixels, lines or pages) |
3 |
Caching related property
| Evernt object property |
Property description |
HOME |
| persisted |
Returns whether the webpage was cached by the browser |
|
A property related to the hash position on the page
| Evernt propertyobject |
Property description |
HOME |
| newURL |
Returns the URL of the document, after the hash has been changed |
|
| oldURL |
Returns the URL of the document, before the hash was changed |
|