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

Adobe AIR Development

Reply
Developer
Posts: 178
Registered: ‎04-16-2011
My Device: torch 9800
My Carrier: verizon
Accepted Solution

Specific Keyboard Events

Hi all,

 

I read a post showing how to show and hide the keyboard, i then was able to listen for typing  by hiding a textbox behind the keyboard.

 

However, I cant seem to find a way to listen for when a user presses the backspace on the keyboard of the playbook, i would forever be grateful if anyone knows a way as I am at a loss.

 

Regards

 

 

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Specific Keyboard Events

Try this:

 



this.mytext.textField.addEventListener( KeyboardEvent.KEY_UP, KeyUp );

 

////////////////////////////////////////////////////////////////////////
private function KeyUp( event : KeyboardEvent ) : void
{
	if( event.keyCode == Keyboard.BACK) // capture enter key
	{
		// do something
	}
}

 

Developer
Posts: 178
Registered: ‎04-16-2011
My Device: torch 9800
My Carrier: verizon

Re: Specific Keyboard Events

Very nice!

 

Thank you very much jtegen.

 

 

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Specific Keyboard Events

By the way, you likely don't need that "text field hidden behind keyboard" trick... if you just want to get the events, attach the listener to the stage:

stage.addEventListener(KeyboardEvent.KEY_UP, KeyUp);

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 439
Registered: ‎10-25-2010
My Device: Not Specified

Re: Specific Keyboard Events

On Android it proves more reliable to attach to your NativeApplication so you can intercept the native BACK button event.

 

So, best practice imo is:
NativeApplication.nativeApplication.addEventListener... 

Developer
Posts: 439
Registered: ‎10-25-2010
My Device: Not Specified

Re: Specific Keyboard Events

Oh, and just fyi "Keyboard.BACK" is not backspace, it's the Android BACK button.

Highlighted
Developer
Posts: 128
Registered: ‎03-18-2011
My Device: PlayBook
My Carrier: verizon

Re: Specific Keyboard Events


shawnblais wrote:

Oh, and just fyi "Keyboard.BACK" is not backspace, it's the Android BACK button.



It should be Keyboard.BACKSPACE. I read this post earlier and didn't catch that. Smiley Very Happy