Skip to content Skip to sidebar Skip to footer

Override Existing Onkeydown Function

My extensions go through every input entered on an on any website that is loaded. What I do is I consider every onkeydown and manipulate it if it has some value. my background js

Solution 1:

Instead of document.onkeydown = returnKey;, use

document.addEventListener('keydown', returnKey, true);

The most important part of this line is the third argument. When the value of this parameter is true, the event listener is triggered at capturing phase, which cannot be prevented using event.preventDefault(); or event.stopPropagation();.

Post a Comment for "Override Existing Onkeydown Function"