Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome Extension Send Key

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.

like image 330
Hassan Voyeau Avatar asked Jun 09 '11 16:06

Hassan Voyeau


2 Answers

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.

like image 107
serg Avatar answered Nov 01 '22 11:11

serg


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

like image 43
yonran Avatar answered Nov 01 '22 11:11

yonran