J2ME: Getting key codes on SE K700i

  • Thread starter Tor Iver Wilhelmsen
  • Start date
T

Tor Iver Wilhelmsen

I run the following little thingy in a midlet, but I only get key
codes for the keys 1, 3, 0, "back" and "C". Is there a reason other
keys don't report anything?

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.game.GameCanvas;

public class KeyScanner extends GameCanvas {

public KeyScanner() {
super(true);
}

public void keyPressed(int keyCode) {
Graphics g = getGraphics();
int x = getWidth(), y = getHeight();
g.setColor(0xffffff);
g.fillRect(0, 0, x, y);
g.setColor(0x000099);
g.drawString(String.valueOf(keyCode), x/2, y/2, 0);
flushGraphics();
}

}
 
D

Darryl Pierce

Tor said:
I run the following little thingy in a midlet, but I only get key
codes for the keys 1, 3, 0, "back" and "C". Is there a reason other
keys don't report anything?
<snip>

Try extending Canvas rather than GameCanvas.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top