Overview of built-in events in JS
| JavaScript
Mouse Events
| Event |
Description |
HOME |
| onclick |
The event occurs when the user clicks on an element |
2 |
| oncontextmenu |
The event occurs when the user right-clicks on an element to open a context menu |
3 |
| ondblclick |
The event occurs when the user double-clicks on an element |
2 |
| onmousedown |
The event occurs when the user presses a mouse button over an element |
2 |
| onmouseenter |
The event occurs when the pointer is moved onto an element |
2 |
| onmouseleave |
The event occurs when the pointer is moved out of an element |
2 |
| onmousemove |
The event occurs when the pointer is moving while it is over an element |
2 |
| onmouseover |
The event occurs when the pointer is moved onto an element, or onto one of its children |
2 |
| onmouseout |
The event occurs when a user moves the mouse pointer out of an element, or out of one of its elements
children
|
2 |
| onmouseup |
The event occurs when a user releases a mouse button over an element |
2 |
Keyboard Events
| Event |
Description |
HOME |
| onkeydown |
The event occurs when the user is pressing a key |
2 |
| onkeypress |
The event occurs when the user presses a key |
2 |
| onkeyup |
The event occurs when the user releases a key |
2 |
Events related to the form
| onblur |
The event occurs when an element loses focus |
2 |
| onchange |
The event occurs when the content of a form element, the selection, or the checked state have
changed (for <input>, <keygen>, <select>, and <textarea>)
|
2 |
| onfocus |
The event occurs when an element gets focus |
2 |
| onfocusin |
The event occurs when an element is about to get focus |
2 |
| onfocusout |
The event occurs when an element is about to lose focus |
2 |
| oninput |
The event occurs when an element gets user input |
3 |
| oninvalid |
The event occurs when an element is invalid |
3 |
| onreset |
The event occurs when a form is reset |
2 |
| onsearch |
The event occurs when the user writes something in a search field (for <input=”search”>)
|
3 |
| onselect |
The event occurs after the user selects some text (for <input> and <textarea>) |
2 |
| onsubmit |
The event occurs when a form is submitted |
2 |
Screen touch events
| Event |
Description |
HOME |
| ontouchcancel |
The event occurs when the touch is interrupted |
|
| ontouchend |
The event occurs when a finger is removed from a touch screen |
|
| ontouchmove |
The event occurs when a finger is dragged across the screen |
|
| ontouchstart |
The event occurs when a finger is placed on a touch screen |
|
Drag and drop events
| Event |
Description |
HOME |
| ondrag |
The event occurs when an element is being dragged |
3 |
| ondragend |
The event occurs when the user has finished dragging an element |
3 |
| ondragenter |
The event occurs when the dragged element enters the drop target |
3 |
| ondragleave |
The event occurs when the dragged element leaves the drop target |
3 |
| ondragover |
The event occurs when the dragged element is over the drop target |
3 |
| ondragstart |
The event occurs when the user starts to drag an element |
3 |
| ondrop |
The event occurs when the dragged element is dropped on the drop target |
Media events
| Event |
Description |
HOME |
| onabort |
The event occurs when the loading of a media is aborted |
3 |
| oncanplay |
The event occurs when the browser can start playing the media (when it has buffered
enough to begin)
|
3 |
| oncanplaythrough |
The event occurs when the browser can play through the media without
stopping for buffering
|
3 |
| ondurationchange |
The event occurs when the duration of the media is changed |
3 |
| unemptied |
The event occurs when something bad happens and the media file is suddenly
unavailable (like unexpectedly disconnects)
|
3 |
| onended |
The event occurs when the media has reached the end (useful for messages like “thanks for listening”) |
3 |
| onerror |
The event occurs when an error occurred during the loading of a media file |
3 |
| onloadeddata |
The event occurs when media data is loaded |
3 |
| onloadedmetadata |
The event occurs when meta data (like dimensions and duration) are loaded |
3 |
| onloadstart |
The event occurs when the browser starts looking for the specified media |
3 |
| onpause |
The event occurs when the media is paused either by the user or
programmatically
|
3 |
| onplay |
The event occurs when the media has been started or is no longer paused |
3 |
| onplaying |
The event occurs when the media is playing after having been paused or stopped for buffering |
3 |
| onprogress |
The event occurs when the browser is in the process of getting the media
data (downloading the media)
|
3 |
| onratechange |
The event occurs when the playing speed of the media is changed |
3 |
| onseeked |
The event occurs when the user is finished moving/skipping to a new position
in the media
|
3 |
| onseeking |
Theevent occurs when the user starts moving/skipping to a new position in
the media
|
3 |
| onstalled |
The event occurs when the browser is trying to get media data, but data is not
available
|
3 |
| onsuspend |
The event occurs when the browser is intentionally not getting media data |
3 |
| ontimeupdate |
The event occurs when the playing position has changed (like when the user
fast forwards to a different point in the media)
|
3 |
| onvolumechange |
The event occurs when the volume of the media has changed (includes setting the
volume to “mute”)
|
3 |
| onwaiting |
The event occurs when the media has paused but is expected to resume (like
when the media pauses to buffer more data)
|
3 |
Animation and transition events
| Event |
Description |
HOME |
| animationend |
The event occurs when a CSS animation has completed |
3 |
| animationiteration |
The event occurs when a CSS animation is repeated |
3 |
| animationstart |
The event occurs when a CSS animation has started |
3 |
| transitionend |
The event occurs when a CSS transition has completed |
3 |
View events
| Event Name |
Fired When |
| fullscreenchange |
An element was turned to fullscreen mode or back to normal mode. |
| fullscreenerror |
It was impossible to switch to fullscreen mode for technical reasons or because the permission was denied. |
| resize |
The document view has been resized. |
| scroll |
The document view or an element has been scrolled. |
Clipboard events
| Event Name |
Fired When |
| cut |
The selection has been cut and copied to the clipboard |
| copy |
The selection has been copied to the clipboard |
| paste |
The item from the clipboard has been pasted |
Printing events
| Event Name |
Fired When |
| beforeprint |
The print dialog is opened |
| afterprint |
The print dialog is closed |
WebSocket events
| Event Name |
Fired When |
| open |
A WebSocket connection has been established. |
| message |
A message is received through a WebSocket. |
| error |
A WebSocket connection has been closed with prejudice (some data couldn’t be sent for example). |
| close |
A WebSocket connection has been closed. |
Network events
| Event Name |
Fired When |
| online |
The browser has gained access to the network. |
| offline |
The browser has lost access to the network. |
Resource Events
| Event Name |
Fired When |
| DOMContentLoaded |
The document has finished loading (but not its dependent resources). |
| cached |
The resources listed in the manifest have been downloaded, and the application is now cached. |
| error |
A resource failed to load. |
| abort |
The loading of a resource has been aborted. |
| load |
A resource and its dependent resources have finished loading. |
| beforeunload |
The window, the document and its resources are about to be unloaded. |
| unload |
The document or a dependent resource is being unloaded. |
Events related to progress
| Event Name |
Fired When |
| loadstart |
Progress has begun. |
| progress |
In progress. |
| error |
Progression has failed. |
| timeout |
Progression is terminated due to preset time expiring. |
| abort |
Progression has been terminated (not due to an error). |
| load |
Progression has been successful. |
| loadend |
Progress has stopped (after “error”, “abort” or “load” have been dispatched). |
You can view a list of all events on MDN.