File Upload - Change key code for ENTER key on Browse Button

Discussion in 'Javascript' started by bsm, May 10, 2007.

  1. bsm

    bsm Guest

    Hi,

    I have File Upload control in my form. When I click Enter key, it
    triggers "Submit" button event. So I wrote onkeydown function as
    follows:

    if (window.event.keycode == 13)
    {
    return false;
    }.

    hence "Submit" button didn't fire.

    But I want to assign Spacebar keycode as follows (so that it will open
    file upload window)

    if (window.event.keycode == 13) window.event.keycode=32. But this is
    not working.

    Can anyone plz help me.
    bsm, May 10, 2007
    #1
    1. Advertising

  2. bsm

    Erwin Moller Guest

    bsm wrote:

    > Hi,
    >
    > I have File Upload control in my form. When I click Enter key, it
    > triggers "Submit" button event. So I wrote onkeydown function as
    > follows:
    >
    > if (window.event.keycode == 13)
    > {
    > return false;
    > }.
    >
    > hence "Submit" button didn't fire.
    >
    > But I want to assign Spacebar keycode as follows (so that it will open
    > file upload window)
    >
    > if (window.event.keycode == 13) window.event.keycode=32. But this is
    > not working.


    What about:
    if (window.event.keycode == 32){
    // code to fire up your file-upload-thingy.
    }

    And if you want people using a real internetbrowser to use your app, I
    suggest you change your code so it catches those events too.
    window.event is IE only...

    Regards,
    Erwin Moller


    >
    > Can anyone plz help me.
    Erwin Moller, May 10, 2007
    #2
    1. Advertising

  3. bsm

    bsm Guest

    On May 10, 7:01 pm, Erwin Moller
    <> wrote:
    > bsm wrote:
    > > Hi,

    >
    > > I have File Upload control in my form. When I click Enter key, it
    > > triggers "Submit" button event. So I wrote onkeydown function as
    > > follows:

    >
    > > if (window.event.keycode == 13)
    > > {
    > > return false;
    > > }.

    >
    > > hence "Submit" button didn't fire.

    >
    > > But I want to assign Spacebar keycode as follows (so that it will open
    > > file upload window)

    >
    > > if (window.event.keycode == 13) window.event.keycode=32. But this is
    > > not working.

    >
    > What about:
    > if (window.event.keycode == 32){
    > // code to fire up your file-upload-thingy.
    >
    > }
    >
    > And if you want people using a real internetbrowser to use your app, I
    > suggest you change your code so it catches those events too.
    > window.event is IE only...
    >
    > Regards,
    > Erwin Moller
    >
    >
    >
    >
    >
    > > Can anyone plz help me.- Hide quoted text -

    >
    > - Show quoted text -- Hide quoted text -
    >
    > - Show quoted text -


    Thanks a lot. your solution worked well.
    bsm, May 11, 2007
    #3
  4. bsm

    Guest

    Hi.
    I have a samll doubt regarding file-upload button.
    By default there will be "Browse" on type="file" button.
    Can i make it to visible as button which bears "Load"(any other word
    other than browse).
    Please make it clear for me if u knew it.

    Thanks in advance
    Regards
    Rajesh P
    , May 29, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bsm
    Replies:
    0
    Views:
    1,300
  2. BrianDH

    Enter Key H*ll, control enter key submit button

    BrianDH, Jan 12, 2005, in forum: ASP .Net Web Controls
    Replies:
    3
    Views:
    388
    Anders Matthiessen
    Jan 12, 2005
  3. Matt
    Replies:
    1
    Views:
    503
    Michael Winter
    Mar 6, 2004
  4. Replies:
    0
    Views:
    205
  5. Replies:
    8
    Views:
    488
Loading...

Share This Page