Results 1 to 6 of 6

Thread: Keystroke?

  1. #1

    Thread Starter
    Hyperactive Member GamerMax5's Avatar
    Join Date
    Nov 2004
    Location
    United States
    Posts
    388

    Question Keystroke?

    I want to make a command button default, meaning that when the user presses the enter button, the button code is executed. How do I do that?
    Only those who try will become.

    Find me on identi.ca

    Twitter @gfmartin05

    Linux Wrap

  2. #2
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877

    Re: Keystroke?

    Quote Originally Posted by GamerMax5
    I want to make a command button default, meaning that when the user presses the enter button, the button code is executed. How do I do that?
    In HTML? If you have a submit button that becomes the default button. If you have more then one form then submit button for the active form (the form which has focus) will be executed.

    If its not HTML you are talking about, then please clarify.
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

  3. #3

    Thread Starter
    Hyperactive Member GamerMax5's Avatar
    Join Date
    Nov 2004
    Location
    United States
    Posts
    388

    Re: Keystroke?

    In VBScript.
    Only those who try will become.

    Find me on identi.ca

    Twitter @gfmartin05

    Linux Wrap

  4. #4
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877

    Re: Keystroke?

    Quote Originally Posted by GamerMax5
    In VBScript.
    I am sorry, i am kinda lost. Can you explain what exactly you are trying to do?
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

  5. #5
    Hyperactive Member Disiance's Avatar
    Join Date
    Sep 2004
    Location
    Denver, CO
    Posts
    439

    Re: Keystroke?

    He wants to detect the [ENTER] key and then submit a form -- no matter what one the page has focus...
    so something like:
    Code:
    <head>
    <script language="VBScript">
    Function handleKeyPress
        If pressedKey = 13 Then document.MyForm.submit
    End Function
    </script>
    <body onKeyPress="handleKeyPress()">
    I know in there somewhere you have to pass the event data, but I don't know where. Also I'm not sure if "document.MyForm.submit" is exactly correct, but it should point you down the right path.
    "I don't want to live alone until I'm married" - M.M.R.P

  6. #6
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877

    Re: Keystroke?

    Quote Originally Posted by Disiance
    He wants to detect the [ENTER] key and then submit a form -- no matter what one the page has focus...
    so something like:
    Code:
    <head>
    <script language="VBScript">
    Function handleKeyPress
        If pressedKey = 13 Then document.MyForm.submit
    End Function
    </script>
    <body onKeyPress="handleKeyPress()">
    I know in there somewhere you have to pass the event data, but I don't know where. Also I'm not sure if "document.MyForm.submit" is exactly correct, but it should point you down the right path.

    Well then the following should be what exactly he is looking for. Note it will only work in IE.

    HTML Code:
    <html>
    <head>
    <script language="VBScript">
    Function handleKeyPress
        if (window.event.keyCode =13) then
    	myfunction
        end if
    End Function
    
    function myFunction
    	msgbox "You have pressed Enter Key"
             'Your default code goes here......
    
    end function
    
    </script>
    <body onKeyPress="handleKeyPress()">
    <form>
    <input type=text>
    <br>
    <input type=text>
    <br>
    <input type=text>
    <select>
    <option>hello</option>
    </select>
    <body
    </html>
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

Posting Permissions

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



Click Here to Expand Forum to Full Width