JavaScript How do you do Keyup Event in Javascript.
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: How do you do Keyup Event in Javascript.

Hybrid View

  1. #1
    Join Date
    Dec 2009
    Posts
    596

    How do you do Keyup Event in Javascript.

    Hello everyone.

    I'm trying to code either the keyup or keypress event for an input field in javascript but can't find any good sample code on how to do it. The example on www.w3schools.com doesn't work for me. Can someone please help me with this?

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,871

    Re: How do you do Keyup Event in Javascript.

    It's pretty basic code. Not sure how W3Schools could mess it up.

    Code:
    <script type="text/javascript">
    function chkKey(e) {
      if (e.keyCode == 13) {
        window.alert("Return key");
      }
    }
    </script>
    
    <input type="text" name="textbox" onkeydown="chkKey(event)">
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Dec 2009
    Posts
    596

    Re: How do you do Keyup Event in Javascript.

    I replaced the body of the function with a simple alert('test'); just to simplify it some and tested the code in IE and Firefox and it worked just fine. Super thanks my friend.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center