title: Clear text field after keypress enter
body: <p>I'm using a simple chat script and need a way to clear the text field after pressing enter.</p>
  
  <p>I got it to clear text field on mouse click with <code>onfocus</code> but keypress eludes me. Also is there a way to do both with one command to make the code cleaner?</p>
  
  <pre><code>&lt;form onsubmit="chat.sendMsg(); return false;"&gt;
      &lt;input onfocus="if(this.value !== '') {this.value=''}" onblur="if(this.value == '')" type="text" id="msg" name="msg" autofocus="true" placeholder="Type Your Meassage Here" /&gt;
      &lt;input type="submit" value="Enter" /&gt;
  &lt;/form&gt;
  </code></pre>