PDA

View Full Version : How to find user has stopped the typing ..



pankaj.ghadge
11-05-2008, 01:29 PM
Hello ,

Suppose User is typing in text. He will see the notification that he is typing. when user will stop the typing then he will see the notification that user has entered the text.

like in gmail chatting we get the notification that user is typing and when user stops typing he gets the notification he has entered the text ..............

Consider one text box and div will show notification .......
How to do this using javascript .......................................


Please tell me ..............................

rangana
11-05-2008, 02:38 PM
Might work:


<script type="text/javascript">
window.onload=function()
{
document.getElementById('test').onkeypress=function()
{
var show=document.getElementById('test1');
show.firstChild.nodeValue='You are typing...';
}
document.getElementById('test').onkeyup=function()
{
var show=document.getElementById('test1');
setTimeout(function()
{
show.firstChild.nodeValue='You are no longer typing.';
},2000); // Listen for 2 seconds of silence
}
}
</script>
<h3 id="test1">You are not typing yet</h3>
<textarea id="test">

</textarea>