Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #12902

Re: onkeydown and onkeyup

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From "Mel Smith" <med_cutout_syntel@aol.com>
Newsgroups comp.lang.javascript
Subject Re: onkeydown and onkeyup
Date Mon, 19 Mar 2012 09:54:52 -0700
Lines 106
Message-ID <9sp6n1Fqr9U1@mid.individual.net> (permalink)
References <fva0m7pct2kfuppli6otfhu6emoeqs6sd2@4ax.com> <jjrlj7$di9$1@speranza.aioe.org> <2eu2m718r5tn1jp7uah2dsv3aa8gj3gi6q@4ax.com> <97a3ca53-f073-4409-abb1-da50fb5cdd2a@a20g2000yql.googlegroups.com> <fc24m71e51g23002bfev0diu0ougats06a@4ax.com>
X-Trace individual.net CfcoxIwSw6+GLST+Ljod9g51XTq3HNuZxCUfXiLMtB6DAe0Phl
Cancel-Lock sha1:rspBf30k+FDHAJLMtSEPB5zBYBs=
X-Priority 3
X-MSMail-Priority Normal
X-Newsreader Microsoft Outlook Express 6.00.2900.5931
X-RFC2646 Format=Flowed; Original
X-MimeOLE Produced By Microsoft MimeOLE V6.00.2900.6157
Xref csiph.com comp.lang.javascript:12902

Show key headers only | View raw


Hi Gene & Mark:

    I've been following your interplay, and hope you don't mind my playing 
Mr. 'Buttinsky' here

Gene said:
>>> I can filter <Enter> in IE 9. I want to avoid having a form be
>>> submitted that way.
>>

    and David Mark replied:

>>No you don't (you just think you do). Leave it alone.

Hi Gene:

    I have over 50 input fields on my Editing page (most <input type="text"> 
but also <textarea> and a few checkbox elements), and use the following 
statement to capture keystrokes (including the <Enter> key) as follows:

     ... in a big loop of all the <input type="text"> I have

    e.onkeydown = focusOnElement  ; // where e. is the input text object, 
and I examine the input

    // the focusOnElement function is my own and is inserted below:

-Mel Smith

*******************
// note that I use the <enter> key to move thru the input fields as they 
occur,
// but I also use the up/down arrow keys to allow my user to move up and 
down thru
// four rows of very structured columns in a table.
// btw, my main user *wants* it this way.

function focusOnElement(e) {
   if (e == null ) e = window.event ;
   var nkey = e.keyCode ;
   var thistab = this.tabIndex;
   var thisid = inpobjs[thistab] ;  // we may need the current id
   var nexttab = (thistab+1 < maxtab) ? thistab+1 : 0 ; // if last goto top
   var prevtab = (thistab-1 < 0) ? maxtab : thistab-1 ; // if already to, 
goto bottom
   var nextid = inpobjs[nexttab] ; // get the id of the next input text 
field
   var previd = inpobjs[prevtab] ; // get the id of the previous input text 
field

   if (nkey === 13) { // enter key
     document.getElementById(nextid).focus() ;
     return true ;
   }

   if (nkey === 40) { // down arrow key
     if (thistab <= 23) {  // then we are in one of the vertical table 
fields
      nexttab += 7     // this should move us down the table vertically
      nextid = inpobjs[nexttab] ; // get the correct id of the input text 
field
     }
     if (thistab >= 24 && thistab <= 31) {
      document.getElementById("ioccupant-1").focus()
      return true ;
      }
     document.getElementById(nextid).focus() ;
     return true ;
   }

   else if(nkey===38) { // up-arrow key
     if (thistab >= 0 && thistab <= 7) {     // don't go anywhere -- stay 
here
      previd = thisid ;
      }

     if (thistab >= 8 && thistab <= 31) {  // then we are in one of the 
vertical table fields
      prevtab -= 7     // this should move us up the table vertically
      previd = inpobjs[prevtab] ; // get the correct id of the input text 
field
     }
     document.getElementById(previd).focus() ;
     return true ;
   }

   else if(nkey===36) { // Home key -- go left or up (i.e., previous field
     document.getElementById(previd).focus() ;
     return true ;
   }

   else if(nkey===33) { // page-up key
     previd = inpobjs[0] ;
     document.getElementById(previd).focus() ;
     return true ;
   }
   else if(nkey===34) { // page-down key
      nextid = inpobjs[maxtab-1] ;
      document.getElementById(nextid).focus() ;
      return true ;
   }
   return true;
}


Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

onkeydown and onkeyup Gene Wirchenko <genew@ocis.net> - 2012-03-13 22:35 -0700
  Re: onkeydown and onkeyup David Mark <dmark.cinsoft@gmail.com> - 2012-03-13 22:40 -0700
  Re: onkeydown and onkeyup Norman Peelman <npeelmandog@cfl.rr.com> - 2012-03-14 17:59 -0400
    Re: onkeydown and onkeyup David Mark <dmark.cinsoft@gmail.com> - 2012-03-14 15:10 -0700
      Re: onkeydown and onkeyup Gene Wirchenko <genew@ocis.net> - 2012-03-14 17:57 -0700
        Re: onkeydown and onkeyup David Mark <dmark.cinsoft@gmail.com> - 2012-03-14 19:39 -0700
  Re: onkeydown and onkeyup "J.R." <groups_jr-1@yahoo.com.br> - 2012-03-14 23:53 -0300
    Re: onkeydown and onkeyup David Mark <dmark.cinsoft@gmail.com> - 2012-03-14 20:26 -0700
    Re: onkeydown and onkeyup Gene Wirchenko <genew@ocis.net> - 2012-03-14 22:13 -0700
      Re: onkeydown and onkeyup David Mark <dmark.cinsoft@gmail.com> - 2012-03-14 22:40 -0700
        Re: onkeydown and onkeyup Gene Wirchenko <genew@ocis.net> - 2012-03-15 08:25 -0700
          Re: onkeydown and onkeyup "J.R." <groups_jr-1@yahoo.com.br> - 2012-03-18 13:07 -0300
            Re: onkeydown and onkeyup David Mark <dmark.cinsoft@gmail.com> - 2012-03-19 00:05 -0700
          Re: onkeydown and onkeyup "Mel Smith" <med_cutout_syntel@aol.com> - 2012-03-19 09:54 -0700
            Re: onkeydown and onkeyup Gene Wirchenko <genew@ocis.net> - 2012-03-19 12:37 -0700
              Re: onkeydown and onkeyup "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-03-19 20:53 +0000
                Re: onkeydown and onkeyup Gene Wirchenko <genew@ocis.net> - 2012-03-19 16:20 -0700
                Re: onkeydown and onkeyup Jeff North <jnorthau@yahoo.com.au> - 2012-03-20 12:12 +1100
                Re: onkeydown and onkeyup Gene Wirchenko <genew@ocis.net> - 2012-03-19 18:45 -0700
                Re: onkeydown and onkeyup Jeff North <jnorthau@yahoo.com.au> - 2012-03-20 17:17 +1100
                Re: onkeydown and onkeyup David Mark <dmark.cinsoft@gmail.com> - 2012-03-20 16:37 -0700
                Re: onkeydown and onkeyup Gene Wirchenko <genew@ocis.net> - 2012-03-20 19:25 -0700
                Re: onkeydown and onkeyup Dr J R Stockton <reply1212@merlyn.demon.co.uk.not.invalid> - 2012-03-21 19:27 +0000
                Re: onkeydown and onkeyup Gene Wirchenko <genew@ocis.net> - 2012-03-21 19:19 -0700
                Re: onkeydown and onkeyup "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-03-22 16:06 +0000
                Re: onkeydown and onkeyup Gene Wirchenko <genew@ocis.net> - 2012-03-22 09:59 -0700
                Re: onkeydown and onkeyup "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-03-22 18:10 +0000
                Re: onkeydown and onkeyup Tim Streater <timstreater@greenbee.net> - 2012-03-22 19:19 +0000
                Re: onkeydown and onkeyup Mike Duffy <Use_guestbook_page@website.in.sig> - 2012-03-23 01:44 +0000
                Re: onkeydown and onkeyup Gene Wirchenko <genew@ocis.net> - 2012-03-22 12:36 -0700
                Re: onkeydown and onkeyup "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-03-23 09:05 +0000
              Re: onkeydown and onkeyup "Mel Smith" <med_cutout_syntel@aol.com> - 2012-03-19 15:49 -0700
      Re: onkeydown and onkeyup Ross McKay <au.org.zeta.at.rosko@invalid.invalid> - 2012-03-16 12:59 +1100
        Re: onkeydown and onkeyup Gene Wirchenko <genew@ocis.net> - 2012-03-15 21:58 -0700
          Re: onkeydown and onkeyup Ross McKay <au.org.zeta.at.rosko@invalid.invalid> - 2012-03-16 18:13 +1100
            Re: onkeydown and onkeyup Gene Wirchenko <genew@ocis.net> - 2012-03-16 08:11 -0700
              Re: onkeydown and onkeyup John G Harris <john@nospam.demon.co.uk> - 2012-03-16 16:58 +0000
                Re: onkeydown and onkeyup Gene Wirchenko <genew@ocis.net> - 2012-03-16 12:05 -0700
        Re: onkeydown and onkeyup Dr J R Stockton <reply1211@merlyn.demon.co.uk.not.invalid> - 2012-03-17 19:13 +0000
          Re: onkeydown and onkeyup Ross McKay <au.org.zeta.at.rosko@invalid.invalid> - 2012-03-18 12:46 +1100
            Re: onkeydown and onkeyup David Mark <dmark.cinsoft@gmail.com> - 2012-03-17 19:13 -0700
            Re: onkeydown and onkeyup Gene Wirchenko <genew@ocis.net> - 2012-03-17 23:27 -0700

csiph-web