I'd like to see all the events fired by an input field as a user interacts with it. This includes stuff like:
- Clicking on it.
- Clicking off it.
- Tabbing into it.
- Tabbing away from it.
- Ctrl+C and Ctrl+V on the keyboard.
- Right click -> Paste.
- Right click -> Cut.
- Right click -> Copy.
- Dragging and dropping text from another application.
- Modifying it with Javascript.
- Modifying it with a debug tool, like Firebug.
I'd like to display it using console.log
. Is this possible in Javascript/jQuery, and if so, how do I do it?
Open Google Chrome and press F12 to open Dev Tools. Go to Event Listener Breakpoints, on the right: Click on the events and interact with the target element.
jQuery and console. log are unrelated entities, although useful when used together. If you use a browser's built-in dev tools, console. log will log information about the object being passed to the log function.
Event methods trigger or attach a function to an event handler for the selected elements. The following table lists all the jQuery methods used to handle events. Method / Property.
I have no idea why no-one uses this... (maybe because it's only a webkit thing)
Open console:
monitorEvents(document.body); // logs all events on the body monitorEvents(document.body, 'mouse'); // logs mouse events on the body monitorEvents(document.body.querySelectorAll('input')); // logs all events on inputs
$(element).on("click mousedown mouseup focus blur keydown change",function(e){ console.log(e); });
That will get you a lot (but not all) of the information on if an event is fired... other than manually coding it like this, I can't think of any other way to do that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With