title: How to get the value of a textbox on keypress event in javascript
body: <p>I am making a chrome extension in which I want to do some string replacement in the text when the enter key is pressed in a focussed textarea. Here is the code snippet:</p>
  
  <pre><code>var elems = document.getElementById("ChatTabsPagelet").getElementsByTagName("textarea"),i;
  matchClass = "uiTextareaAutogrow";
  
  for (i in elems) {
      if((' ' + elems[i].className + ' ').indexOf(' ' + matchClass + ' ')&gt; -1) {
      text = elems[i].value;          
              elems[i].onkeyup = function(evt) {
                if(evt.keyCode == 13){
                 alert(elems[i].value);
                }
        };
     }
  }
  </code></pre>
  
  <p>Basically I am looking for all the textareas with the class <em>uiTextareaAutogrow</em> and I just want to access their values when the enter key is pressed in any of those textareas. However, I always get <em>undefined</em> in the alert box when I try the extension out on a webpage. I guess the keyup event is fired but it is not able to get a handle to the particular textarea. Where am I going wrong?</p>
  
  <p>Note: I am keen on using javascript only(not jquery) as I want the extension to be really light. </p>