1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Function Onkeypress for cursor key

Discussion in 'JavaScript and AJAX' started by newphpcoder, Nov 8, 2010.

  1. newphpcoder

    newphpcoder New Member

    Joined:
    Sep 24, 2010
    Messages:
    101
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Web Programmer
    Location:
    Philippines
    Good day!
    In my javascript code I have a function for the enter key. I want to add cursor key in that function/ I research about the coding for cursor key but I can't find the code same on what I want to happen.
    Here is the code:
    Code:
    <script language="javascript">
      function handleEnter(e, nextfield)
            {
            var characterCode = (e && e.which)? e.which: e.keyCode;
            if(characterCode == 13)
                {
                document.getElementById(nextfield).focus();
                return false;
                } 
            else
                {
                return true;
                }
            }
        </script>
    <input type='text' name='plt' onkeypress='return handleEnter(event,\"b0\");' />
    
    Thank you
     

Share This Page