Hello Fellows :)
I am trying to find a way to get more than one characters pasted on html text field (input type=text), using onkeydown or onkeypress, I am NOT interested in onkeyup(it works), so please do not suggest me this solution. Also I am not interested in Jquery, I do not like to use it. I need solution to work with all browsers.
I am able to do that if you type one character, by taking the character of the event, but till now I am unable to get group of characters come from the paste (ctrl+V) or by mouse.
You can look at Facebook search menu that shows auto complete results, it works on events: onkeydown and onkeypress and you notice that you get the result before you release your finger, try to paste something (more than one character) and you get the result before releasing finger, how? Onkeypress and onkeydown do not show first thing you paste or type because they happen before the text being added to text field.
If you want to understand what I want more, please check my code below:
<input type="text" id="targetTextField" onkeydown="CapturePastedString(this.id)" />
<script>
function CapturePastedString(id){
var targetTextField=document.getElementById(id);
// below I need to capture the pasted string like:
var pasted_string= function(){.....}
targetTextField.value=pasted_string;
}
</script>
Any help would be so thankful, because since long time I am trying but cannot find solution yet.