title: Auto-scroll <textarea> with Javascript
body: <p>I have this textarea that shows inputted text, but when the number of lines exceeds the size and width of the textarea, the user has to scroll down to see what they have last inputted.</p>
  
  <p>I'd like the textarea to be set to the bottom everytime the enter button is pressed.</p>
  
  <p>I've tried the following, but I can't get it to work:</p>
  
  <pre><code>function inputKeyDown(evt, input) {    
      if (evt.keyCode == 13) {    
          var textarea = document.getElementById("textarea");  
          textarea.value += "\n" + "&gt;" + " " + input.value;  
          input.value = "";  
          return false;       
      }  
      var elem = document.getElementById('textarea');  
      elem.scrollTop = elem.scrollHeight;    
  } 
  </code></pre>
  
  <p>and then I call the function keyDown in <code>&lt;input onKeyDown="return keyDown(event, this);" ...&gt;</code></p>
  
  <p>Any idea why no workie?</p>