Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
dillirao
Posts: 29
Registered: ‎09-29-2008
My Device: Not Specified

how to capture the keyRepeated() event in Blcakberry?

Hi,

 

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)

{

System.out.println("keyPressed() called.");

}

 

public void keyRepeated(int keycode)

{

System.out.println("keyRepeated() called.");

}

public void keyReleased(int keycode)

{

System.out.println("keyReleased() called.");

}

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.

 

Thanks,

Manoj.

 

 

Please use plain text.
Administrator
MSohm
Posts: 14,410
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: how to capture the keyRepeated() event in Blcakberry?

What BlackBerry model and handheld software version are you testing on?  You can find this under Options, About on the BlackBerry handheld.  Are you holding down a key on your keyboard or holding down a key (using the mouse) on the BlackBerry Simulator itself?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
New Developer
blicket
Posts: 4
Registered: ‎10-24-2008
My Device: Not Specified

Re: how to capture the keyRepeated() event in Blcakberry?

related question: how do you simulate key press hold + another key (ie alt+back) on the blackberry simulator?   Thanks
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: how to capture the keyRepeated() event in Blcakberry?

"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.

Please use plain text.
Developer
almeida
Posts: 91
Registered: ‎02-04-2009
My Device: Not Specified

Re: how to capture the keyRepeated() event in Blcakberry?

Does  BlackBerry support the keyRepeated() callback for Canvas objects in MIDlets?  In the simulator and on a device (9000, v4.6.0.92), 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. 

Please use plain text.
Developer
RLord321
Posts: 343
Registered: ‎02-23-2009
My Device: 8700 | 8310 | BOLD | STORM

Re: how to capture the keyRepeated() event in Blcakberry?

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.

Please use plain text.
Developer
almeida
Posts: 91
Registered: ‎02-04-2009
My Device: Not Specified

Re: how to capture the keyRepeated() event in Blcakberry?

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.

Please use plain text.