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
Developer
azdragon2
Posts: 38
Registered: ‎02-04-2009
My Device: 9530

Handling Key_ESCAPE

hey guys,

 

I want the back button (KEY_ESCAPE) to react in the exact same way as the End button (KEY_END).

I first tried to use the getKeyCode method, but I don't know what to send as the character to represent the Escape button.

Then I just inserted the actual keycode for KEY_END, but for some reason this returns false and does not execute. Depending on how the method is handled, the time may not match up or the keycodes may vary so thats why its producing this result, I figure. I just want to send my program into the standby mode as a background program and take them back to the menu without actually "Exiting" the application. Any ideas?

 

Here's the code I've ben using that doesn't work right:

 

protected boolean keyDown(int keycode, int time)
    {
        System.out.println("KEYCODE: " + keycode);
        if (Keypad.key(keycode) == Keypad.KEY_ESCAPE)
        {
            super.keyDown(1179648,time);
            return true;
        }
        return super.keyDown(keycode,time);
    }

Please use plain text.
Developer
RexDoug
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Handling Key_ESCAPE

Use keyChar(), and catch Characters.ESCAPE

 

 

 

 

Please use plain text.
Developer
azdragon2
Posts: 38
Registered: ‎02-04-2009
My Device: 9530

Re: Handling Key_ESCAPE

So I've created this:
protected boolean keyDown(int keycode, int time)
    {
        System.out.println("KEYCODE: " + keycode);
        if (Keypad.key(keycode) == Keypad.KEY_ESCAPE)
        {
             super.keyChar(Characters.ESCAPE,  KeypadListener.STATUS_NOT_FROM_KEYPAD, time);
             return true;
        }
        return super.keyDown(keycode,time);
    }

 

I don't want ESCAPE though, I want the END button, I don't see a character for it. Do you know what it is?

Please use plain text.
Developer
simon_hain
Posts: 16,010
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Handling Key_ESCAPE

Keypad.KEY_END, or keycode 1114112
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
azdragon2
Posts: 38
Registered: ‎02-04-2009
My Device: 9530

Re: Handling Key_ESCAPE

If you're suggesting doing this:
super.keyDown(1114112,time);

it doesn't work.

 

There's nothing I can do with Keypad.KEY_END except look up the keycode. And the keycode won't work in this manner.

Please use plain text.
Developer
simon_hain
Posts: 16,010
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Handling Key_ESCAPE

you have to use input simulation / keystroke injection to press keys programatically.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
azdragon2
Posts: 38
Registered: ‎02-04-2009
My Device: 9530

Re: Handling Key_ESCAPE

I tried doing this keystroke injection but I keep getting stuck on the Characters interface not having a END key character. So I ended up just programming the ESCAPE key to do exactly what I wanted.

 

I appreciate the help guys. Thanks again.

Please use plain text.