javascript - Fire Key event from chrome extension: Uncaught TypeError: Cannot read property 'ime' of undefined -
i'm trying fire key events when clicking on chrome extension button.
manifest:
... "background": { "scripts": ["a.js"] }, "permissions": [ "activetab", "input" ], ...
a.js
chrome.browseraction.onclicked.addlistener(function(tab) { ... chrome.tabs.executescript({ file: "script.js" }); });
script.js
var e = new keyboardevent("keydown", {bubbles : false, cancelable : true, key : "left"}); var e2 = new keyboardevent("keyup", {bubbles : false, cancelable : true, key : "left"}); chrome.input.ime.sendkeyevents({contextid:0, keydata:[e, e2]}, function() {console.log("callback");});
what console prints is: uncaught typeerror: cannot read property 'ime' of undefined
im on chrome 35 / ubuntu 12.04
thank you!
this indicates chrome.input.ime
api not available content scripts, chrome apis.
you must operate background script.
Comments
Post a Comment