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
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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.