×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    24

    KeyCode for Arrows

    Hi ...

    What are the value of the KeyCodes for UP, DOWN, LEFT, and RIGHT ???

    Regards,

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    There are game actions for the arrows:
    Code:
    void keyPressed(int keyCode) {
      int gameAction = getGameAction(keyCode);
      switch(gameAction) {
        case UP:
          // ...
        case DOWN:
          // ...
        // ...
        case FIRE:
          // ...
      }
    }
    If you really have to know the keycode for the arrows you can get the getKeyCode(int gameAction) method:
    Code:
    // all this methods are part of the Canvas class
    // so assuming you are IN a Canvas
    int upKeyCode = getKeyCode(UP);
    You should do a little digging in the javadocs before asking this because it's all in there.

    shmoove

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×