Created
July 11, 2016 07:38
-
-
Save sinpaout/acbf971076de7ab1bdd93616313d13ce to your computer and use it in GitHub Desktop.
dispatch Enter key's keypress event.
This file contains hidden or 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
// for detail http://stackoverflow.com/questions/8942678/keyboardevent-in-chrome-keycode-is-0/12522752#12522752 | |
var ev = document.createEvent('Events'); | |
ev.initEvent('keypress', true, true); | |
ev.keyCode = 13; | |
ev.which = 13; | |
ev.charCode = 13; | |
ev.key = 'Enter'; | |
ev.code = 'Enter'; | |
document.querySelector('.new-todo').dispatchEvent(ev); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment