How to stop keypress
event in keydown
.
I have a keydown
handler in that I need to stop keypress
event.
Actually I have a form and textbox in it.
When user press enter key, keydown
is triggering the event and having the handler.
Form submit will triggered be in keypress
, so I need to stop the keypress
event in my keydown
handler.
function onKeyDown(event) {
event.preventDefault();
}
http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-Event-preventDefault
or
function onsubmit(event) {
return false;
}
return false to stop events propagation