Jump to content

Function Onkeypress for cursor key

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
newphpcoder

newphpcoder

    Programming Professional

  • Members
  • PipPipPipPipPipPip
  • 477 posts
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:

<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

#2
by0logic

by0logic

    Newbie

  • Members
  • PipPip
  • 19 posts
I don't know if that could helps but there's an onClick attribute similar to that onKeyPress one.