Removeeventlistener Doesn't Work
I have this very strange case that prevents me from removing eventListener. This is a very simple function that binds to keyboard events and unbinds (in theory) when is not needed.
Solution 1:
You need to give the same function reference for removing from the event handler. Every time when you call the keyboardEvents
, you create a new function with name
keyboardFunction
, so there are different from a call to call. So why you can't remove it.
Try this code Codepen.
Post a Comment for "Removeeventlistener Doesn't Work"