Is it possible with jQuery to automatically simulate a press on a keyboard, f.ex. inside an html input field?
As explanation: If I press the a inside an
It seems to me as if the goal is not necessarily to mimic a native browser keypress event, but to manipulate text inside an input field.
If I'm right, you can fetch the .prop('selectionStart')
and .prop('selectionEnd')
values and overwrite any characters within those indexes by the character(s) you want to "keypress". You can accompany this by triggering of appropriate keyboard events.
I've never worked on text selection before. I know IE handles things differently than normal browsers, so you'll need to look into this topic and find a cross-browser solution if you choose to walk this path. To make things perfect, you'll need to change the selection properties after modifying the input's value as if it were a native paste.