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
Contributor
Posts: 27
Registered: ‎05-10-2012
My Device: bold 9700
My Carrier: Vodafone

ON KeyDown Event certain action does not work??

I am using a KeyDown event to move a shape across the screen but it seems I have to press it release my finger from the key and press it again for things to work, I want to keep my hand on the key and it to continuosly do what I have instructed it to do?? 

 

 public boolean keyDown(int keycode, int time) {
		if (Keypad.key(keycode) == Keypad.KEY_SHIFT_LEFT)
		{
			left = true;
			MovePlayer();
			
			return true;
		} else if (Keypad.key(keycode) == Keypad.KEY_SHIFT_RIGHT)
		{
			right = true;
			MovePlayer();
			
			return true;
		}
		
		if (Keypad.key(keycode)== Keypad.KEY_SPACE)
		{
			space = true;
			//spaceActivity();
		}
		
		return false;
	}
	

 

Highlighted
Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: ON KeyDown Event certain action does not work??

Try overriding keyRepeat method.

 

Here is a link to the docs:

http://www.blackberry.com/developers/docs/5.0.0api/net/rim/device/api/system/KeyListener.html#keyRep...

 

E.