I am trying to set keyCode on dispatched event object .
On button click, event is raised on textbox control to simulating keydown event. Event is raised successfully
This happens because (as others have stated) the KeyboardEvent object (which uses charCode instead of keyCode) is being called instead of the Event object. When you are using:
function txtKeydown(e) {
console.dir(e);
console.log(e.keyCode);
}
if you're getting a 0
printed to the console, try using e.charCode
instead of e.keyCode
refer to MDN web docs for more information regarding KeyboardEvent: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent