views:

155

answers:

1

The adobe documentation says that when listening for a keypress event from a phone you should listen for Key.Down, however when I trace the Key.getCode() of keypresses I see a number not the string "Key.Down". I am tesing this locally in device central and do not have a phone to test this with at present. Here is my code -

keyListener = new Object();
keyListener.onKeyDown = function() {
    switch (Key.getCode()) {
    trace(Key.getCode()) // outputs 40
        case (Key.DOWN) : // according to the docs
          pressDown();
        break;
    }
}

My question is - is this simply because Im testing in device central and when I run it on the phone I will need to be listening for Key.Down? or is the documentation wrong? Also is the numeric code (40) consistent across all devices? What gives adobe?

thanks all

+1  A: 

Key.Down is equal to 40 so it will recognize it as the same. So you can use whichever one you prefer, however, I would recommend using Key.Down because it will be easily recognizeable for those who dont have Key Codes memorized (most of us).

These are the Key Code Values for Javascript. However, I think they are pretty much universal

jmein