Capture a keydown or keypress?

Discussion in 'Javascript' started by George Hester, Dec 29, 2003.

  1. When the address bar is highligted? That is nothing on the page is selected. The address bar is selected. Capture keydown or keypress? Any ideas using javascript? Thanks.

    --
    George Hester
    __________________________________
     
    George Hester, Dec 29, 2003
    #1
    1. Advertising

  2. George Hester

    rf Guest

    "George Hester" <> wrote in message
    news:Bz1Ib.12434$...
    When the address bar is highligted? That is nothing on the page is
    selected. The address bar is selected. Capture keydown or keypress? Any
    ideas using javascript? Thanks.

    Can't be done.

    Cheers
    Richard.
     
    rf, Dec 30, 2003
    #2
    1. Advertising

  3. George Hester

    Steve Guest

    On Mon, 29 Dec 2003 22:06:25 GMT, George Hester typed:

    >When the address bar is highligted? That is nothing on the page is selected. The address bar is selected.
    > Capture keydown or keypress? Any ideas using javascript? Thanks.


    If the address bar is highlighted, windows focus will be on the browser,
    not the document so the browser will see the keypress, not the
    document. What you want to do just won't work



    --
    SSS,
    Steve / Strathclyde / Scotland.
    ------------------------------
     
    Steve, Dec 30, 2003
    #3
  4. Thanks. That takes care of that. Using any other technology?

    --
    George Hester
    __________________________________
    "rf" <> wrote in message news:_o7Ib.69721$...
    >
    > "George Hester" <> wrote in message
    > news:Bz1Ib.12434$...
    > When the address bar is highligted? That is nothing on the page is
    > selected. The address bar is selected. Capture keydown or keypress? Any
    > ideas using javascript? Thanks.
    >
    > Can't be done.
    >
    > Cheers
    > Richard.
    >
    >
     
    George Hester, Dec 30, 2003
    #4
  5. George Hester

    kaeli Guest

    In article <eOeIb.20432$>,
    enlightened us with...
    > Thanks. That takes care of that. Using any other technology?


    I believe using IE6+ and a WSH it might be possible...
    But that's just a guess. :)

    Otherwise you'd have to use .net and a custom browser extenstion.

    --
    --
    ~kaeli~
    A hangover is the wrath of grapes.
    http://www.ipwebdesign.net/wildAtHeart
    http://www.ipwebdesign.net/kaelisSpace
     
    kaeli, Dec 30, 2003
    #5
  6. George Hester

    rf Guest

    "George Hester" <> wrote in message
    news:eOeIb.20432$...
    Thanks. That takes care of that. Using any other technology?

    What precicely are you trying to do?

    --
    George Hester
    __________________________________
    "rf" <> wrote in message
    news:_o7Ib.69721$...
    >
    > "George Hester" <> wrote in message
    > news:Bz1Ib.12434$...
    > When the address bar is highligted? That is nothing on the page is
    > selected. The address bar is selected. Capture keydown or keypress? Any
    > ideas using javascript? Thanks.
    >
    > Can't be done.
    >
    > Cheers
    > Richard.
    >
    >
     
    rf, Dec 31, 2003
    #6
  7. Basically what I was trying to do I've given up. The idea was to determine what the tabIndex was upon tabbing through my controls on a form and hitting the address bar. I have 5 controls. 4 on the form and 1 on a link. So there are only 5 "elements" which get the tab. 0, 1, 2, 3 on the form and 4 is the link. I number them explicitly this way. But onkeydown over the 4th one, the link, sends control to the address bar. At that point I cannot capture onkeydown. onkeydown over the link is not captured (fired) when the key is the TAB and the place the cursor goes is the address bar.

    The trouble is my tabIndex seems to act inconsistently when the address bar is included in the mix.

    --
    George Hester
    __________________________________
    "rf" <> wrote in message news:BSoIb.70900$...
    >
    > "George Hester" <> wrote in message
    > news:eOeIb.20432$...
    > Thanks. That takes care of that. Using any other technology?
    >
    > What precicely are you trying to do?
    >
    > --
    > George Hester
    > __________________________________
    > "rf" <> wrote in message
    > news:_o7Ib.69721$...
    > >
    > > "George Hester" <> wrote in message
    > > news:Bz1Ib.12434$...
    > > When the address bar is highligted? That is nothing on the page is
    > > selected. The address bar is selected. Capture keydown or keypress? Any
    > > ideas using javascript? Thanks.
    > >
    > > Can't be done.
    > >
    > > Cheers
    > > Richard.
    > >
    > >

    >
    >
     
    George Hester, Dec 31, 2003
    #7
  8. George Hester

    Grant Wagner Guest

    <form>
    <input type="text" name="one" tabindex="1">
    <input type="text" name="two" tabindex="2">
    <input type="text" name="three" tabindex="3">
    <input type="text" name="four" tabindex="4" onblur="this.form.elements['one'].focus();">
    </form>

    Doesn't help if the user hits SHIFT+TAB in the first form element however.

    George Hester wrote:

    > Basically what I was trying to do I've given up. The idea was to determine what the tabIndex was upon tabbing through my controls on a form and hitting the address bar. I have 5 controls. 4 on the form and 1 on a link. So there are only 5 "elements" which get the tab. 0, 1, 2, 3 on the form and 4 is the link. I number them explicitly this way. But onkeydown over the 4th one, the link, sends control to the address bar. At that point I cannot capture onkeydown. onkeydown over the link is not captured (fired) when the key is the TAB and the place the cursor goes is the address bar.
    >
    > The trouble is my tabIndex seems to act inconsistently when the address bar is included in the mix.
    >
    > --
    > George Hester
    > __________________________________
    > "rf" <> wrote in message news:BSoIb.70900$...
    > >
    > > "George Hester" <> wrote in message
    > > news:eOeIb.20432$...
    > > Thanks. That takes care of that. Using any other technology?
    > >
    > > What precicely are you trying to do?
    > >
    > > --
    > > George Hester
    > > __________________________________
    > > "rf" <> wrote in message
    > > news:_o7Ib.69721$...
    > > >
    > > > "George Hester" <> wrote in message
    > > > news:Bz1Ib.12434$...
    > > > When the address bar is highligted? That is nothing on the page is
    > > > selected. The address bar is selected. Capture keydown or keypress? Any
    > > > ideas using javascript? Thanks.
    > > >
    > > > Can't be done.
    > > >
    > > > Cheers
    > > > Richard.


    --
    | Grant Wagner <>

    * Client-side Javascript and Netscape 4 DOM Reference available at:
    * http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/frames.html
    * Internet Explorer DOM Reference available at:
    * http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtml_reference_entry.asp
    * Netscape 6/7 DOM Reference available at:
    * http://www.mozilla.org/docs/dom/domref/
    * Tips for upgrading JavaScript for Netscape 7 / Mozilla
    * http://www.mozilla.org/docs/web-developer/upgrade_2.html
     
    Grant Wagner, Jan 2, 2004
    #8
  9. George Hester

    Evertjan. Guest

    Grant Wagner wrote on 02 jan 2004 in comp.lang.javascript:

    > <form>
    > <input type="text" name="one" tabindex="1">
    > <input type="text" name="two" tabindex="2">
    > <input type="text" name="three" tabindex="3">
    > <input type="text" name="four" tabindex="4"
    > onblur="this.form.elements['one'].focus();"> </form>
    >
    > Doesn't help if the user hits SHIFT+TAB in the first form element
    > however.


    You can use to "hidden" inputs that only act as tab and shift-tab catch.
    They cannot be visibility:hidden or display:none, just style zero-sized.

    The tab sequence will be 234523452...

    The shift-tab sequence will be 5432543254....

    Try:

    <script>tabn=false;</script>
    <form>
    <input style="width:0;height:0;" tabindex="1"
    onfocus="if(tabn){tabn=false;this.form.elements['four'].focus();}">
    <input type="text" name="one" tabindex="2" onkeydown="tabn=true">
    <input type="text" name="two" tabindex="3">
    <input type="text" name="three" tabindex="4">
    <input type="text" name="four" tabindex="5">
    <input style="width:0;height:0;" tabindex="6"
    onfocus="this.form.elements['one'].focus();">
    </form>

    IE6 tested.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Jan 2, 2004
    #9
    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. Chris Calhoun
    Replies:
    1
    Views:
    282
    Jim Cheshire [MSFT]
    Oct 10, 2003
  2. jaspal singh

    trap keypress and keydown event in asp.net mobile form

    jaspal singh, Nov 24, 2006, in forum: ASP .Net Mobile
    Replies:
    1
    Views:
    1,438
  3. Jens Butm

    KeyDown/KeyPress is not working... ??

    Jens Butm, Oct 19, 2007, in forum: ASP .Net Mobile
    Replies:
    0
    Views:
    865
    Jens Butm
    Oct 19, 2007
  4. Simon Blanco

    How to capture a keypress

    Simon Blanco, Jun 17, 2008, in forum: Ruby
    Replies:
    5
    Views:
    106
    Simon Blanco
    Jun 20, 2008
  5. Hans

    Capture keypress inside a textarea

    Hans, Jun 23, 2004, in forum: Javascript
    Replies:
    1
    Views:
    103
    Martin Honnen
    Jun 24, 2004
Loading...

Share This Page