Sharepoint - Adding a Google Search Box

This code is working for me:

$(document).ready(function(){
// check if enter button is pressed and then search button clicked event is called
    $('#txtSearch').keypress(function(e){
      if(e.keyCode==13)
      $('#btnSearch').click();
       return 1;
    });
});

What's happening is that the OOTB Submit handler for the page is getting in the road.

You can add some script like this to disable the enter key firing the submit action for the page. Fair warning: I've not tested this beyond verification that it fixes your problem, unintended consequences may abound.

<script type="text/javascript">
function stopSumbitOnEnter(evt) { 
var evt = (evt) ? evt : ((event) ? event : null); 
var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); 
if ((evt.keyCode == 13) && (node.type=="text")) {return false;} 
} 

document.onkeypress = stopSumbitOnEnter; 
</script>
<div align="center">
<input type="text" onKeyDown="if(event.keyCode==13) doSearch();" id="SearchQuery" size="100">
<br/><br/>
<button type="button" onclick="javascript:doSearch();">Search</button>
</div>

<script type="text/javascript">
function doSearch(){
    var theSearchQuery = document.getElementById('SearchQuery');
    var theURLToGoTo =  "https://www.google.com/webhp?#q=" + theSearchQuery.value;
    window.location= theURLToGoTo;
}
</script>

Disable script lifted from: http://webcheatsheet.com/javascript/disable_enter_key.php