title: How to check if a user has stopped typing in an input field?
body: <p>I have an indicator that notifies users when another user is typing by looking for a keypress on an input box. However, if the user removes what they were typing, the indicator still shows other users that they're still typing. How can I alter this to remove the indicator when the input field is empty.</p>
  
  <p>The indicator will disappear when the message is sent, by setting <code>istyping</code> to an empty string. I'm not sure how to utilise this to detect an empty input field.</p>
  
  <pre><code>var message = document.getElementById('messagebox');
  var istyping = document.getElementById('istyping');
  
  message.addEventListener('keypress', function(){
      socket.emit('typing', {
          user: user || 'Anonymous'
      })
  })
  
  socket.on('typing', function(data){
      istyping.innerHTML = '&lt;p&gt;&lt;i&gt;'+ data.user +" is typing..."+'&lt;/p&gt;&lt;/i&gt;';
  })
  </code></pre>