You Are Here:

Community: Developer Discussion Boards

#1 Old Using the arrow keys (up & down) on 6310i? - 2002-06-17, 07:50

Join Date: Mar 2003
Posts: 39
bjajo780
Offline
Registered User
How do I use Up & Down key in my applications on my 6310i? I have searched the forum and the only useful information I have found is that those keys corresponds to KEY_UP_ARROW and KEY_DOWN_ARROW, but I still don't know how to use these constants. Can someone please help me with this?

Somewhere someone talked about a KeyListener but I can't find this in my API's! Maybe that KeyListener wasn't for 6310i...

A small code example would be perfect!

/Bjarne Johannessen

#2 Old RE: Using the arrow keys (up & down) on 6310i? - 2002-06-17, 16:19

Join Date: Mar 2003
Posts: 71
AbU5e
Offline
Regular Contributor
Canvas defines the methods keyPressed and keyReleased methods. These are called when the corresponding event occurs.

Canvas also defines the method 'getGameAction(int keyCode)'
and constants Canvas.DOWN,Canvas.UP,Canvas.LEFT etc etc

extend Canvas, and override the keyPressed method with something like this...

public void keyPressed(int keyCode)
{
int gameAction = getGameAction(keyCode);
//btw there is a bug with getGameAction(int),
//if you pass in -6 or -7 (the keyCodes for the
//left and right soft keys, the emulator crashes!)
switch(gameAction)
{
case UP:
System.out.println("UP Pressed");
break;
case DOWN:
System.out.println("DOWN Pressed");
break;
case LEFT:
System.out.println("LEFT Pressed");
break;
case RIGHT:
System.out.println("RIGHT Pressed");
break;
default:
System.out.println("Some other key pressed");
}
}

#3 Old RE: Using the arrow keys (up & down) on 6310i? - 2002-06-18, 07:03

Join Date: Mar 2003
Posts: 39
bjajo780
Offline
Registered User
Perfect!

That did work on my first CTRL+C & CTRL-V attempt. Thank you =)

/Bjarne
Closed Thread « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

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

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia