If you want to trigger the keypress or keydown event then all you have to do is:
var e = jQuery.Event("keydown");
e.which = 50; // # Some key code value
$("input").trigger(e);
More Related Contents:
- jQuery Event Keypress: Which key was pressed?
- Changing the keypress
- jquery keypress event object keyCode for firefox problem?
- How to capture the browser window close event?
- How to set file input value when dropping file on page? [duplicate]
- How to order events bound with jQuery
- Firing event on DOM attribute change
- How to trigger the window resize event in JavaScript?
- Detect multiple keys on single keypress event in jQuery
- Triggering a JavaScript click() event at specific coordinates
- How to unbind a listener that is calling event.preventDefault() (using jQuery)?
- Handling key-press events (F1-F12) using JavaScript and jQuery, cross-browser
- How can I listen for a click-and-hold in jQuery?
- How to get JQuery.trigger(‘click’); to initiate a mouse click
- jQuery: How to get the event object in an event handler function without passing it as an argument?
- Listening for Youtube Event in JavaScript or jQuery
- jQuery: Unbind event handlers to bind them again later
- How do you detect the clearing of a “search” HTML5 input?
- JS Events: hooking on value change event on text inputs
- How can I get jQuery .val() AFTER keypress event?
- jQuery event that triggers after CSS is loaded?
- jQuery events .load(), .ready(), .unload()
- Performance difference between jQuery’s .live(‘click’, fn) and .click(fn)
- Get the clicked object that triggered jquery blur() event [duplicate]
- Drop event not firing in chrome
- Prevent onclick action with jQuery
- jQuery: How to listen for DOM changes?
- jquery/javascript: function(e){…. what is e? why is it needed? what does it actually do/accomplish?
- Fire oninput event with jQuery
- addEventListener to iFrame