Let’s look at how to debug all JavaScript events and log them to the console with a nifty trick.

It’s for example important when debugging a web page to see how many submit events a form element sends out.

With this debugging method you prevent sending and tracking  browser events multiple times.

Listen for all events in JavaScript

There is a handy API in Chrome Developer Tools that makes this easy.

The  monitorEvents API allows you to log any occuring JavaScript event to the console in Chrome. You just have to give it an element and optionally the event you want to listen to:

monitorEvents(element[,event])

If you want to stop listening for events again, you simply use:

unmonitorEvents(element[,event])

Example: Log all click events of the window object to the console

#javascript #programming

A Simple Guide to Log JavaScript Events to the Console for Debugging
2.60 GEEK