There is a lot of contents on this in stack overflow but none seems to work for my case. I have an input text field and I want to simulate keypress event to fill the text fi
You will not be able to fire an event that will cause text to populate an input. See this snippet from MDN:
Note: manually firing an event does not generate the default action associated with that event. For example, manually firing a key event does not cause that letter to appear in a focused text input. In the case of UI events, this is important for security reasons, as it prevents scripts from simulating user actions that interact with the browser itself.
Thanks @gforce301
Your best bet may be to set the value and then dispatch an event.