0

I want to ignore, remove, or stop all keydown events bounded to a DOM.

I have used the following code. but it just works in the console. I need to run it on the page and out of the console.

var events = getEventListeners(document);
var keydowns = events.keydown;

keydowns.forEach(element => {

    document.removeEventListener(element.type, element.listener);

});

The problem is getEventListeners() function is defined only in the console and is undefined on the page.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Hamid Javadi
  • 201
  • 2
  • 7
  • 1
    `getEventListeners(obj)` is only a Google Chrome specific Command Line Tool feature https://stackoverflow.com/questions/46974675/iterate-geteventlisteners-return-object – Sascha Aug 20 '20 at 10:17
  • 1
    Does this answer your question? [Iterate getEventListeners() return object](https://stackoverflow.com/questions/46974675/iterate-geteventlisteners-return-object) – Sascha Aug 20 '20 at 10:18
  • Interesting article [List EVERY event that exists in the browser](https://www.perimeterx.com/tech-blog/2019/list-every-event-that-exists-in-the-browser/) – pilchard Aug 20 '20 at 10:26
  • @Sascha I need an alternative way to gain events and remove them that working on the page. – Hamid Javadi Aug 21 '20 at 11:19

0 Answers0