[英]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? 在javascript中,有没有一种方法可以检测或覆盖(以'null')应用于DOM元素的所有onkeyup和onkeydown处理程序,而不是迭代整个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). (在这种情况下,我希望覆盖扩展程序可能已插入到DOM上的onkey处理程序,例如通过浏览器扩展程序,而不是直接检测站点添加的处理程序)。
If you are able to use jQuery, I think this code could help you 如果您能够使用jQuery,我认为这段代码可以为您提供帮助
$( document ).off('keypress').on('keypress', 'SELECTOR', function(e){
// your code
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.