Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find out if there is Javascript code that is listening to keyboard events?

How can I find out if there is Javascript code listening/intercepting keyboard events and ideally find the exact line/location in the code (e.g. in ChromeDev Tools)?

like image 648
Yolgie Avatar asked Jul 23 '18 13:07

Yolgie


People also ask

How do you check if a key is pressed JavaScript?

In plain JavaScript, you can use the EventTarget. addEventListener() method to listen for keyup event. When it occurs, check the keyCode 's value to see if an Enter key is pressed.

Which event is specific to the keyboard in JavaScript?

There are three different keyboard events in JavaScript: keydown : Keydown happens when the key is pressed down, and auto repeats if the key is pressed down for long. keypress : This event is fired when an alphabetic, numeric, or punctuation key is pressed down. keyup : Keyup happens when the key is released.

Which is not a keyboard event in JavaScript?

5. Which of the following are not key event properties? Explanation: altKey, ctrlKeY, shiftKey, and metaKey are key event object's properties, which are set to true if the corresponding modifier key is held down when the event occurs.


2 Answers

My Answer is for Chrome Browser

  • If you need to View event listeners registered on objects then you can use getEventListeners(object)
  • If you need to monitor events use monitorEvents()

You can read more about these API

You can also observe these events from the Dev tools

enter image description here

like image 106
Hyyan Abo Fakher Avatar answered Nov 01 '22 09:11

Hyyan Abo Fakher


I don't know on others brows but at least in chrome console in elements tab on the right side you can open the Event Listeners tab and see them all, moreover clicking on it You will find where they have been set.enter image description here

like image 28
fedeghe Avatar answered Nov 01 '22 10:11

fedeghe