You can trigger any of the events with a direct call to them, like this:
$(function() {
$('item').keydown();
$('item').keypress();
$('item').keyup();
$('item').blur();
});
Does that do what you're trying to do?
You should probably also trigger .focus()
and potentially .change()
If you want to trigger the key-events with specific keys, you can do so like this:
$(function() {
e = $.Event('keypress');
e.which = 65; // A
$('item').trigger(e);
});
There is some interesting discussion of the keypress events here: http://stackoverflow.com/questions/302122/jquery-event-keypress-which-key-was-pressed, specifically regarding cross-browser compatability with the .which property.
ebynum
2010-07-30 03:51:02