title: Prevent page reload on enter key pressed
body: <p>i have the following input field:</p>
  
  <pre><code>&lt;input type="text" id="txt_comment" class="form-control" placeholder="Skriv kommentar"&gt; 
  </code></pre>
  
  <p>with this i have the following code    </p>
  
  <pre><code>    $('#txt_comment').keyup(function(e){
      if(e.keyCode == 13)
      {
          addComment();
          return false;
      }
      e.preventDefault();
  });
  </code></pre>
  
  <p>However when i press enter it still reloads the page. Can anyone tell me what im doing wrong?</p>
  
  <p><strong>Update</strong> </p>
  
  <pre><code>    function addComment()
  {
      var comment = $('#txt_comment').val();
      {
          $.ajax({
              type: 'POST',
              url: '/Comment/addComment',
              dataType: 'json',
              data: {
                  request: 'ajax',
                  reciver:user_id,
                  comment: comment
              },
              success: function (data)
              {
                  $('#comment_list').prepend(
                      '                                        &lt;li class="list-group-item animated fadeInRightBig"&gt;'+
                  '        &lt;p&gt;&lt;b class="text"&gt;'+data['sender']+'&lt;/b&gt;:'+
                  '&lt;br/&gt;'+comment+' &lt;/p&gt;'+
                  '&lt;input  type="hidden" class="timestamp" value="'+data["timestamp"]+'"&gt;'+
                   '   &lt;small class="block text-muted timeSmall"&gt;&lt;i class="fa fa-clock-o"&gt;&lt;/i&gt;&lt;/small&gt;'+
                  '&lt;/li&gt;'
                  )
                  $('.timestamp').each(function()
                  {
                      var text = $(this).next()
                      var timer = $(this).val();
                      var new_text = moment(timer, "YYYY-MM-DD- HH:m:ss").fromNow();
                      text.html(new_text);
  
                  });
                  $('#txt_comment').val('');
  
              }
          })
      }
  }
  </code></pre>
  
  <p>And my function now look like this:</p>
  
  <pre><code>    $('#txt_comment').keyup(function(e){
      if(e.keyCode === 13)
      {
          addComment();
          e.preventDefault();
          return false;
      }
  });
  </code></pre>
  
  <p>Still having page reloads</p>