Linked Questions

Popular Questions

Disable event listener set by external library

Asked by At

In some place of an external library (which, of course, I can't change), an event listener is created this way:

someElement.addEventListener('keydown', function(e) {

I need to get rid of this listener or override it somehow. But it seems that it can't be done, as I don't have any way to reference the anonymous function used.

It's not necessary that this is the only listener removed. Removing ALL the keydown listeners would be also OK, if it were possible.

I've seen that an option would be cloning the element and replace it, but I can't do that, because there is a lot of initialization, and a lot of other events listeners are created. I just need to cancel the keydown one.

Is there anything I can do?

Related Questions