11-26-2008 11:13 AM
I am using j2me canvas (javax.microedition.lcdui.Canvas) for my application.
In thatcode I have written the code like below:
public void keyPressed(int keycode)
public void keyRepeated(int keycode)
public void keyReleased(int keycode)
When I run the applicaiton on emulator:
I got only keyPressed and keyReleased statements on console.
Even I hold any key, I didnt get "keyRepeated()called" statement on console.
What should I do?
can any one help me please.
12-02-2008 04:35 PM
12-11-2008 05:11 PM
"how do you simulate key press hold + another key (ie alt+back)"
Use the PC keyboard - press and hold the CTRL key to hold the Simulator's alt key.
03-12-2009 06:28 PM
Does BlackBerry support the keyRepeated() callback for Canvas objects in MIDlets? In the simulator and on a device (9000, v18.104.22.168), my Canvas gets keyPressed and keyReleased, but it does not get keyRepeated events. In the simulator, pressing and holding keys on my computer keyboard or clicking and holding the simulator keys does not produce keyRepeated. hasRepeatEvents() returns false on the device and in the simulator.
03-12-2009 07:16 PM
I'm not sure what you guys are trying to accomplish here but if you really want to know if any keys are pressed at any given time, you can use getKeyState() of the GameCanvas class--since you aren't using the RIM API's for screens. It extends from Canvas so it shouldnt be a big change. This is not an event but at any point in your code when you want to check the state of the keys, you can call this method. It's very handy...
Too bad the RIM API's don't have an equivalent. Instead, you have to set a flag when you press down on a key and then release the flag on the key up event. It works, but if you are say..building a game, you might need your input at certain times, not during an event--since events can be triggered outside your main loop. So you have to account for this.
With my experience ,keyRepeated is not really what most people want since there is a delay before the key gets repeated. Press and hold a key on your keyboard now. How long does it take for the key to repeat itself. This delay is usually not desired.
07-15-2009 11:08 AM
An old thread, but here is an answer for future reference...
RIM says that key repeat events were not supported for MIDlets in handheld software 4.6.0 and below. In 4.6.1 and higher, keyRepeated should be called and hsaRepeatEvents should return true. This information came from a contact at RIM, but please note that I have not verified the statements.