java midp key listener problems

i implemented a keylistener in a cavas as following

public void keyPressed(int k){

}

i tested it on a nokia ngage, but everytime i am holding down a button the game starts lagging. someone knows a workaround out there?

i finally found the solutions.
the lag was caused by the implementation of the running thread for the main-loop in the Canvas.
instead of using:

public void run(){
while(true){
repaint();

}
}

use:

public void run(){
repaint();

Display.getDisplay(myMidlet).callSerially(this);

}

You need to be aware that many phones have buggy implementations of callSerially(), and it can be unwise to rely on it if you intend on porting the game to many handsets.

Idealy you should make the game loop capable of using either method of looping.

Hey Abuse, do you remember which phones have buggy implementations of callSerially(). I’ve started to use it recently, so I would be interested to know which phones might become a problem.