Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    May 2005
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Simulating Key Strokes

    Hiya Folks,

    I trying to replace the key behaviour when a user presses the ENTER key in a input field. Put simply when a user presses Enter I want to the browser to act as if they'd pressed TAB.

    The code I have so far is as follows :


    function MyDelete(MyName){

    var pKey = window.event.keyCode;

    if(pKey==8||pKey==46) //disable the backspace and delete keys
    {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
    return false;
    }
    else if(pKey == 13) //detect the ENTER key and replace with TAB
    {
    alert("Enter Pressed")

    window.event.keycode = 9

    }

    }
    This function is called from the input field as follows :

    onKeyDown='Mydelete("MyIndex"<%=Mycount%>)'
    The function is detecting that the Enter key has been pressed but it isn't changing the behaviour, which in this case is trying to Subit the form. I'm trying to replace this so the user can enter values into the field press Enter and move onto the next field. Using nothing other than the Number pad on the keyboard.

    This is on an intranet and the only browser is IE

    Any offers?
    Why is there a setting on your toaster that burns your toast?

  • #2
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try adding \t not keyCode 9
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<

  • #3
    New Coder
    Join Date
    May 2005
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    at the risk of ridicule, add it to what??
    Why is there a setting on your toaster that burns your toast?

  • #4
    Senior Coder
    Join Date
    Apr 2005
    Posts
    1,051
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well, looking at your code i'm not quite following how your returning the 'tab' to the textarea (or RichTextDoc).

    However, if you are intercepting the 'enter' and replacing it with a 'tab' then

    \t

    is the escape char for tabs.
    public string ConjunctionJunction(string words, string phrases, string clauses)
    {
    return (String)(words + phrases + clauses);
    }
    <--- Was I Helpfull? Let me know ---<


  •  

    Posting Permissions

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