An event handler is a piece of code associated with an event in the code. An event handler gets executed, when that event occurs.
You can say that event handler is a routine that deals with the event, allowing a programmer to write code that will be executed when the event occurs.
In general, the event handler has the name of the event, preceded by “on”. For example, the event handler for the Focus event is “onFocus”.