Jump to content

terminate onKeyUp after OnKeydown


ted_chou12

Recommended Posts

Hi, I made a textfield that is made to do a certain thing when a key is pressed as onKeydown="event.keycode==13...",  so that's when the enter key is pressed, but I am not sure how you can terminate the onKeyUp function such that when the key is released, the "enter" key does not effect the textarea:


<<the textarea skips a line eventhough func is passed successfully

Ted Chou

Link to comment
https://forums.phpfreaks.com/topic/212977-terminate-onkeyup-after-onkeydown/
Share on other sites

I'm not entirely understanding your question, but do a return false if you don't want the return key to submit the form.

 

Example page:

<html>
<head>
<script type="text/javascript">
function keyDownFunction()
{
    if(window.event.keyCode=='13')
    {
        return false;
    }
}
</script>

</head>
<body>

<form action="here.php" method="POST">
<input type="text" name="dfsf" onkeydown="return keyDownFunction();" />
<button type="submit">Submit</button>

</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.