Skip to content

Instantly share code, notes, and snippets.

@breezhang
Created July 6, 2014 14:09
Show Gist options
  • Save breezhang/b4f77ec6dc290992d2bf to your computer and use it in GitHub Desktop.
Save breezhang/b4f77ec6dc290992d2bf to your computer and use it in GitHub Desktop.
jquery simulate click keypress
$("#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