Getting an input field to submit with the enter key

Hello I’ve been trying to figure out with a search box I’ve added how it can submit by pressing the ‘enter’ key rather than just clicking a ‘submit’ button beside a form. I’ve tried onkeypress but as soon as you press one button the field submits. I’ve also seen you can do with keycode==13 but I’m not sure how to add it into my code. I’ve pasted my code in below. Any help would be much appreciated.

<input type="text" name="Search" id="Search" class="searchBox" />
    <a href="#" onclick="getContentURL(Search.value);"><img src="/img/magnifying-glass.gif" class="searchImg" /></a>
    <script type="text/javascript"> 
function getContentURL(sSearch){
window.location ="/search/pages/Results.aspx?k="+sSearch+"&s=All%20Sites";

The input field needs to be inside a form - both to be valid and for the enter key to be able to trigger whatever is attached to the action attribute of the form tag.

Great thank you for your help. Worked well.