Created
June 24, 2013 01:26
-
-
Save jutememo/5847201 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var event = document.createEvent("KeyEvents"); | |
event.initKeyEvent("keypress", | |
true, | |
true, | |
null, | |
false, // holds Ctrl key | |
true, // holds Alt key | |
false, // holds Shift key | |
false, // holds Meta key | |
0, // presses a special key, @see http://mxr.mozilla.org/mozilla/source/dom/public/idl/events/nsIDOMKeyEvent.idl | |
event.DOM_VK_0 // presses a normal key, e.g. "A".charCodeAt(0), | |
); | |
document.documentElement.dispatchEvent(event); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment