Skip to content

Instantly share code, notes, and snippets.

View kevinkid's full-sized avatar

kevinkid kevinkid

View GitHub Profile
@boazsender
boazsender / keyboard-event-trigger.js
Created October 17, 2011 03:25
Dispatch a keyboard
/*
Chrome does not let you modify the keyCode prop when you trigger it, so it defaults to 0.
You can use this code to trigger a keydown with a char code of 0 in chrome.
If you use initKeyEvent instead of initKeyboardEvent, it will work in FF
(the bellow example would trigger keydown with a char code of 65 in FF).
*/
document.addEventListener( 'keydown', function( event ){
console.log( event.keyCode )