key sequence question

Discussion in 'Javascript' started by Frank L., Jul 10, 2003.

  1. Frank L.

    Frank L. Guest

    Hi. I have this key sequence detection:

    keySeq = 0

    function keyHandler() {

    switch (event.keyCode) {
    case 78:
    if (keySeq==0) {keySeq++}
    break
    case 65:
    if (keySeq==1) {keySeq++}
    keySeq = 2
    break
    case 82:
    if (keySeq==2) {keySeq++}
    keySeq = 2
    break
    case 85:
    if (keySeq==2)
    alert("Hello")
    keySeq = 0
    }
    }


    Is there a way I could put in an 'if' statement so I could say basically "if
    this sequence of keys is pressed, do this action, else if do something else,
    else if....etc, etc.

    Thanks
    Frank
     
    Frank L., Jul 10, 2003
    #1
    1. Advertisements

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. Christian Bongiorno

    custom key and hasmap using a ranged key

    Christian Bongiorno, Jun 15, 2004, in forum: Java
    Replies:
    1
    Views:
    570
    Roedy Green
    Jun 15, 2004
  2. Patrick Guio
    Replies:
    6
    Views:
    3,551
    chris
    Oct 20, 2004
  3. shyam
    Replies:
    8
    Views:
    677
    Priscilla Walmsley
    Jun 21, 2006
  4. Florian Lindner

    key - key pairs

    Florian Lindner, Jun 23, 2005, in forum: Python
    Replies:
    8
    Views:
    818
    Paul McGuire
    Jun 24, 2005
  5. stef mientki
    Replies:
    13
    Views:
    1,015
    stef mientki
    Oct 20, 2007
  6. XML fellow
    Replies:
    2
    Views:
    500
    XML fellow
    Oct 3, 2008
  7. M P
    Replies:
    1
    Views:
    843
  8. Ronnie Bermejo
    Replies:
    1
    Views:
    224
Loading...