Is there a way to completely disable a webpage when the enter button is pressed in an input text element?
I am looking to create a search field in which I can get text when I type in to filter objects and display only those that contain text from the search field.
I tried the following to try to catch the enter button, but it does not work.
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;
}
}
source
share