title: Call a JavaScript function by hitting enter in a textbox without global events of jQuery
body: <p>I am working on a project with the goal of learning, and I am avoiding jQuery thus far to learn as much JavaScript as possible.  I have been successfully using onkeypress to determine whether or not enter was hit in a textbox or textarea, but after adding a searchbar on me website, I discovered that events like onkeypress are global (ie. hitting enter in the search bar activates my 'send message' textarea).</p>
  
  <p>I am also using AJAX, and thus I do not want a simple form submit.  I am also hoping to use a textarea, since I am after multiple lines (so that more text is visible).</p>
  
  <p>Under these constraints, is this reasonable to do without using jQuery?  If so, how can I do it?  Other answers on the site simply point to jQuery.</p>
  
  <p>Thanks,</p>
  
  <p>Paragon</p>
  
  <p>Edit: I was asked for code, so here is the relevant HTML and JavaScript.  Here is one of the inputs:</p>
  
  <pre><code>&lt;input type="text" id="search" name="search" onkeypress="return activate(event, this.value);"/&gt;
  </code></pre>
  
  <p>Here is the javascript to go along with it:</p>
  
  <pre><code>function activate(e, message)
  {   
      if (isNotEnter(e))
      {   
          return true;
      }   
      else // ie. enter was pressed
      {   
          // only proceed to search() if message is not empty
          if (message.length &gt;= 1)
          {   
              search();
          }   
          return false;
      }   
  }
  </code></pre>
  
  <p>And the function isNotEnter():</p>
  
  <pre><code>function isNotEnter(e)
  {   
      if (e.keyCode == 13) 
      {   
          return false;
      }   
      else
      {   
          return true;
      }   
  }
  </code></pre>