简体   繁体   中英

Javascript - detect or override all onkeyup and onkeydown handlers

In javascript, is there a way to detect or override (to 'null') all onkeyup and onkeydown handlers applied to DOM elements, rather than iterate the entire dom?

(I this scenario, I'm looking to override onkey handlers that extensions may have inserted onto the DOM, eg by browser extensions, rather than detect handlers added by the site directly).

If you are able to use jQuery, I think this code could help you

$( document ).off('keypress').on('keypress', 'SELECTOR', function(e){
  // your code
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM