Event Types

An event can be trigger by many different means. How this event is trigger is referred to as an event type. The following are overview of the more common event types. For a more complete list, review to the Event Referenceopen in new window.

Mouse Events

Mouse events occur when the user uses the mouse to interact with the page. While there are many different Mouse Eventsopen in new window, the most common used are click, mouseover, and mouseout.

Keyboard Events

Keyboard eventsopen in new window occur when the user uses the keyboard to interact with the page. There are only three keyboard events: keydown, keyup, and keypress (ignores modifier keys). When a key is pressed the browser will provide a key code that can be used to identify which key was pressed. These codes are retrieved using a property from the Event object. Unfortunately, this part of the API is in the middle of a transition period, so there are two common properties that can be used to retrieve the key code.

The old property is keyCode, which will provide a number that represents the key pressed. This number will be different depending on which keyboard event we are listening for.

The new property is key, which provide a string that represents the key pressed.

Other Standard Events

While the most common events types are going to come from the the mouse or keyboard, there are many other Standard Eventsopen in new window that can be used. The focus event is fired for <input>, <select>, and <textarea> elements when the user is focused on the field and making entering the information.

The change event is fired for <input>, <select>, and <textarea> elements when a change to the element's value is committed by the user.

The submit event is fired when a form is submitted.