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 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Key Launcher works, but add a form to the equation?

    Basically I have got the Key Launcher to work brilliantly and everyone is happy, Then came the question,

    What happens if there is a <input type="text"> in the page?

    Well, when there is a form element in the page, I need to set focus to the form so that when I hit a defined "Hot Key" the page is not redirected and form field doesn't lose focus.

    Can I set Focus to the form so that is escapes the document.onkeypress event?

    Has any one gotten this to work?? if so any hints/tips

    I have looked at other examples on the net and they all seem to suffer the same feat but Im sure there is a way I just haven't found it yet.

    Cheers.

    Phil

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    338
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    document.formName.fieldName.onkeydown = function(e) {
    if(typeof e.stopPropagation != "undefined") e.stopPropagation();
    else event.cancelBubble = true;
    }
    Hope that helps!

    Happy coding!

  • #3
    New Coder
    Join Date
    Aug 2002
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks

    Thanks for the reply, I will let you know how it goes.



  •  

    Posting Permissions

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