Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.