# Having Trouble with Key Input in Mobile Handsets.

This topic is 4059 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey guys. I'm using the value -7 to identify the Right Soft key action in some Nokia Phones... but it doesn't work. In J2ME Polish they say it's the right value. :S I have the Command Listener deactivated. Regards.

##### Share on other sites
Are you using a full screen canvas?

shmoove

Yes I'm.

##### Share on other sites
That's strange. Usually when you don't get events for the softkeys it's either because you are not in full screen mode or because you have added Commands to you Canvas. You say you haven't done either.

You should add some code that draws the key code on the display when a key is pressed and see if it is getting called when you press the softkey, and what code it is giving.

shmoove

##### Share on other sites
Here's the code i'm using. I just don't get it. I use KEY_NUM0 or any other and it doesn't work either. I use the UP_PRESSED and it works. :S Maybe it's because i'm using GameCanvas? Should i use just Canvas?

[EDIT]
I just noticed that if i use just UP, and not UP_PRESSED, it doesn't work. This means that i need to use
Thanks shmoove.

[EDIT2]
Damn... my game is made based on GameCanvas, not on Canvas. :S If thats the problem... ufh, is there anything i can do to avoid adapting it to canvas?

public void inputInGame()    {        if(keyStates==0)        {            keyStates = getKeyStates();            switch(keyStates)            {                case UP_PRESSED:                    break;                case DOWN_PRESSED:                    break;                case LEFT_PRESSED:                    break;                case RIGHT_PRESSED:                    break;                case FIRE_PRESSED:                    break;                case -7:                    isMenuInGame=true;                    break;                default:                    break;            }        }        keyStates = getKeyStates();    }

[Edited by - Goguis on June 10, 2007 12:10:04 PM]

##### Share on other sites
Shmoove! At last I figured it out!. I was using getKeyState() when i should be using

public void keyPressed(int keyCode)
{

}

Ufh, i started to freak out! lol

Thanks for all the help!

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
16
5. 5

• 14
• 29
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631774
• Total Posts
3002274
×