开发者

Chrome Extension Send Key

开发者 https://www.devze.com 2023-03-11 23:22 出处:网络
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.Unfortunately n

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.


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

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.


Right now, you have to read the HTML5 spec and simulate everything that the browser would do. Here was my last attempt at it.

0

精彩评论

暂无评论...
验证码 换一张
取 消