An event listener is a procedure or function in a computer program that waits for an event to occur. Examples of an event are the user clicking or moving the mouse, pressing a key on the keyboard, disk I/O, network activity, or an internal timer or interrupt. The listener is programmed to react to an input or signal by calling the event’s handler.

The term event listener is often specific to Java and JavaScript. In other languages, a subroutine that performs a similar function is called an event handler.

The following JavaScript code would add an event listener to an HTML document:

document.addEventListener(‘click’, myfunction, false);

In this example, when HTML is rendered in a browser, the listener calls the function “myfunction” (defined elsewhere in the script) when the user clicks.

Event, Input, Programming terms, Signal, Subroutine