user2064849
user2064849

Reputation: 23

Trigger System-wide Keyboard Events from a Javascript Chrome App

Is there a way to trigger a system-wide keyboard event (i.e. emulate an actual key being physically pressed) from a Javascript Chrome App?

Currently I've got

target.dispatchEvent(new KeyboardEvent(..));

but this can only be invoked on a target element within the browser.

Ultimately, I want to be able to have a callback

function typeLetter(character){ }

that will type a letter character whether Chrome is the active window or not.

Any suggestions greatly welcomed!

Upvotes: 0

Views: 147

Answers (1)

Tom Dyer
Tom Dyer

Reputation: 452

I'm pretty sure this won't be possible between different applications. Even between browser tabs would be an issue I think. If it were possible there would be plenty of security issues that come with it.

Emulating key presses anywhere except the currently-running application (chrome) would open up a can of worms in regards to cross-site scripting attacks and key-logging hacks.

Upvotes: 2

Related Questions