Chrome扩展程序发送键 [英] Chrome Extension Send Key

查看:151
本文介绍了Chrome扩展程序发送键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来模拟从Chrome扩展的关键preSS?例如,当我点击按钮扩展我可以指定键ABC发送到浏览器窗口。

Is there a way to simulate a key press from a chrome extension? For example when I click the extension button I can specify that keys 'ABC' be sent to browser window.

推荐答案

不幸的是没有(这是一个JavaScript问题,浏览器API不提供任何帮助)。

Unfortunately no (it is a javascript problem, Chrome API doesn't provide any help).

所有你能做的就是派遣关键preSS事件(请参阅这个问题例如),但你不能模拟实际的按钮preSS。如果父页面监听键preSS事件,那么它会抓住它(这种情况下不会有所有的信息作为一个真正的按钮preSS事件,所以它仍然可能无法正常工作),否则什么都不会发生。

All you can do is dispatch a keypress event (see this question for example), but you can't emulate actual button press. If parent page listens to keypress events, then it will catch it (this event won't have all the info as a real button press event, so it might still not work), otherwise nothing would happen.

这篇关于Chrome扩展程序发送键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆