HMTL Events Attributes

An HTML event is an action that gets triggered when a user scrolls, clicks or perform other activities within a browser.

An event is useful so as to know what code to run when a user clicks on a certain element.

Keyboard Events

Attribute Description
onkeyup This event is triggered when a key is released.
onkeydown This event is triggered when a key is being pressed.
onkeypress This event is triggered when a key is pressed
Example


Mouse Events

Attribute Description
onclick This event is triggered when a mouse is clicked on an element.
ondblclick This event is triggered when a mouse is double clicked on an element.
onwheel This event is triggered when a mouse wheel is rolled up or down over an element.
onmousemove This event is triggered when a move pointer is moved over an element.
onmousedown This event is triggered when a mouse button is pressed down on an element.
onmouseup This event is triggered when a mouse pressed button is released over an element.
onmouseover This event is triggered when a mouse pointer moves over on an element.
onmouseout This event is triggered when a mouse pointer moves out of an element.
Example


Clipboard Events

Attribute Description
oncut This event is triggered when a content of an element is cut.
oncopy This event is triggered when a content of an element is copied.
onpaste This event is triggered when a content is pasted in an element.

Form Events

Attribute Description
onsubmit This event is triggered when a form is submitted.
onchange This event is triggered when the value of an element is changed.
onselect This event is triggered when the value of an element is selected.
oninput This event is triggered when the element gets input.
onfocus This event is triggered when the elements gets focused.

Window Events

Attribute Description
onload This event is triggered after a page completes loading.
onunload This event is triggered after a page is unloaded or the browser is closed.
onoffline This event is triggered when a browser starts working offline.
ononline This event is triggered when a browser starts working online.
onresize This event is triggered on resizing a browser window.
onbeforeprint This event is triggered before printing a page document.
onafterprint This event is triggered after a page document is printed.
onbeforeunload This event is triggered before unloading a page or closing a browser.
onerror This event is triggered on encountering an error.