04-09-2009 08:51 AM - edited 04-09-2009 10:07 AM
I am trying to get the keyCode from Canvas.KeyPressed in MIDlet. It seems when enable Multitap, I can't type "B.
My steps:
1. enable Multitap
2. press "shift"
3. press KEY_NUM2 continous twice in short time.
=> At this point, I got "A" and "a", instead of "B".
I wrote a simple MIDlet looks like:
=================================================
public class TouchScreenMIDlet extends MIDlet{
public void destroyApp(boolean unconditional)
throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
public void pauseApp() {
// TODO Auto-generated method stub
}
public void startApp() throws MIDletStateChangeException {
Display.getDisplay(this).setCurrent(new TouchScreenCanvus());
}
}
==================================================
public class TouchScreenCanvus extends BlackBerryCanvas{
TouchScreenCanvus(){
super();
}
public void paint(Graphics g) {
g.fillRect(0, 0, 10, 10);
}
public void keyPressed(int keyCode){
System.out.println("TouchScreenCanvus keyPressed: "+keyCode);
}
}
=================================================
With eclipse plugin emulator(v4.7.0.46), the keyCode prointed is 65 and 97, while I am expecting 66.
If I lock the "shift" key, I can get A, and then B, and then C. But how can I get the correct keyCode without forcing user locking the shift key and yet still get B?
04-10-2009 10:45 AM
04-21-2009 03:23 PM
This is the expected behaviour. When capturing keys presses, the first character on the key (the left most character) is passed in. It is up to the application to handle input for additional letters on the same key. You could detect when the user presses the key twice in rapid succession and substitute for the second character.