большое спасибо, помогло.
function fireEvent(element,event){
// [url]http://jehiah.cz/archive/firing-javascript-events-properly[/url]
// [url]https://developer.mozilla.org/en/DOM/event.initKeyEvent[/url]
if (document.createEventObject){
// dispatch for IE
var evt = document.createEventObject();
return element.fireEvent('on'+event,evt)
}
else{
// dispatch for firefox + others
var evt = document.createEvent("KeyboardEvent");
// create a key event
evt.initKeyEvent(
event, // in DOMString typeArg,
true, // in boolean canBubbleArg,
true, // in boolean cancelableArg,
null, // in nsIDOMAbstractView viewArg, Specifies UIEvent.view. This value may be null.
false, // in boolean ctrlKeyArg,
false, // in boolean altKeyArg,
false, // in boolean shiftKeyArg,
false, // in boolean metaKeyArg,
13, // in unsigned long keyCodeArg,
0); // in unsigned long charCodeArg);
return !element.dispatchEvent(evt);
}
}
fireEvent(document.getElementById('element'), 'keypress');
тему можно закрывать