JavaScript Events

Event interfaces available to event listeners in JavaScript.

  1. The DOMContentLoaded event can be used to tell when a page is fully loaded and ready to run scripts on the page; this may be useful if a script rely on dependencies that must be loaded for the script to work.
  2. the keydown event is not an ideal way to detect text-input by the user; instead you should consider using the input event.

Event interfaces

This category contains a list of event interfaces that may be used from JavaScript code.

Events can be listened for using the addEventListener method in JavaScript; an example would be the DOMContentLoaded event.

An event listener might look like this:

window.addEventListener('DOMContentLoaded', function() {
  console.log('DOM fully loaded.');