在 Javascript 中寻找捕获关键事件的函数?
我正在为一个复杂的网络应用程序编写用户脚本。现有代码正在捕获“j”和“k”keydown
事件。
我希望能够找到这个函数来看看它在做什么。有没有办法列出文档中的所有关键事件处理程序?或者也许有一种方法可以在 Chrome 开发者工具中以某种方式在我按下字母时设置断点?
I'm writing a user script for a complex web app. The existing code is catching the 'j' and 'k' keydown
events.
I'd like to be able to find this function to see what it's doing. Is there a way to list all the key event handlers in a document? Or maybe a way to set a breakpoint somehow in Chrome Developer Tools for when I press the letter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,在开发人员工具中,转到“脚本”选项卡,选择页面,转到“事件侦听器断点”、“键盘”、“keydown” 。
尽管这可能不一定对您有多大帮助,例如,如果脚本被缩小或者他们使用了库。但你可以尝试一下。
Yes, in the developer tools, go to the Scripts tab, select the page, go to Event Listener Breakpoints, Keyboard, keydown.
Though this might not necessarily help you much, e.g. if the script is minified or they use a library. But you can give it a try.
如果您可以先运行脚本的一部分,并且在文档级别处理按键,则可以安装此拦截以查看代码的哪一部分正在设置键盘处理程序:
If you can get a piece of your script to run first and if the keys are handled at the document level, you can install this intercept to see what part of the code is setting the keyboard handler: