I have 3 fields on the page, and when the user has a cursor focused on two of them, I want a certain button to be pressed on the page, which was pressed when they press the enter button. I use
<script language="JavaScript">
function stopRKey(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 = stopRKey;
</script>
To stop the default behavior, I just don't see how to change it to skip some keystrokes. I looked through the http://asquare.net/javascript/tests/KeyCode.html tutorial , but it was not obvious what was happening.
Does anyone know how to do this or a tutorial that goes through this?
source
share