title: Socket.io how to check if user is typing and broadcast it to other users
body: <p>I am trying to setup socket.io chat server. I have gotten it up to send and receive message from server and client. I was interested in showing users if some one is typing. I know i can emit when some is typing from client to server, I can also broadcast it to other users. But will it be efficient to do that on every keyup? How do i handle such situation? Below is my code for now:</p>
  
  <pre><code>$("#textbox").keyup(function (e)  {
   if (e.keyCode == 13)  {
    socket.emit('send', {nickname: $('#nickname').val() , msg: $("#textbox").val()});
        $('#textbox').val('');  }
   else{
    socket.emit('is typing',  {nickname: $('#nickname').val()});
       }
  });
  </code></pre>
  
  <p>and on server side:</p>
  
  <pre><code>socket.on('is typing', function(data){
   socket.broadcast.emit('typing', {nickname: data.nickname});
  });
  </code></pre>