var o = document.createEvent('UIEvents'); o.initUIEvent( 'keyup', true, true, window, 1 ); o.keyCode = 13;