Stop page refreshing when 'enter' is pressed in input text element
<p>Is there a way to stop a webpage from refreshing completely when the enter button is pressed in a input text element?</p>

<p>I'm looking to create a search field that I can get the text from when enter is pressed to filter objects and only display the ones that contain text from the search field.</p>

<p>I've tried the following to try and catch the enter button but it does not work.</p>

<pre><code>function setupSearchField() {
    document.getElementById("searchField").onKeyDown = function(event) {
        var holder;
        if (window.event) {
            holder = window.event.keyCode;
        } else {
            holder = event.which;
        }
        keyPressed(holder);
    }
}

function keyPressed(key) {
    if (key == 13) {
        event.cancelBubble = true;
        return false;
    }
}
</code></pre>
