Created
July 6, 2014 14:09
-
-
Save breezhang/b4f77ec6dc290992d2bf to your computer and use it in GitHub Desktop.
jquery simulate click keypress
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
$("#test4000").keydown(function(e){ | |
console.log("%s %s","enter keypress", e.keyCode); | |
var value = $(this).val() + String.fromCharCode(e.keyCode); | |
$(this).val(value); | |
}) | |
$("#test3000").click(function(){ | |
console.log("enter!"); | |
var e = $.Event("keydown"); | |
e.keyCode = e.which = 50; | |
$("#test4000").trigger(e); | |
}) | |
$(document).keypress(function(e){ | |
if(e.ctrlKey && e.shiftKey && e.keyCode ==5){ | |
location.reload(); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment