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

Web and WebWorks Development

Reply
New Contributor
Posts: 4
Registered: ‎05-17-2010
My Device: Simulator Bold 9700
My Carrier: None

100% 1 page html/javascript web application - capture ESC (BACK) physical button

Using basic jQuery I have my web appliation up and running on BB Bold.  Its 1 web page and I manage the DOM in my javascript, and give the look and feel of many web pages but its still only 1 web page.

 

Trying to keep it like the Android, Nokia and iPhone I would like to capture the Esc (back) key and move it though my application.    My sample test code that only works when the full keyboard is displayed is

 

$(this).keypress(function(event) {

    alert('Handler for .keypress() called. k C='+event.keyCode);


    if ( event.keyCode == 27 )
    {
        event.preventDefault();

        /* Call my routine for a BACK and move though my app */
     }
});

 

 

Is there a way to capture teh ESC key when just on the page without being in a field?  I've tried $(docmuent)... and others and I'm either missing it, or it cant be done, or shooting myself in my foot?

 

Thanks

/Andy

 

 

 

Developer
Posts: 40
Registered: ‎04-16-2010
My Device: na
My Carrier: na

Re: 100% 1 page html/javascript web application - capture ESC (BACK) physical button

New Developer
Posts: 7
Registered: ‎02-26-2011
My Device: Blackberry Bold 9780
My Carrier: telkomsel

Re: 100% 1 page html/javascript web application - capture ESC (BACK) physical button

Yup. You can trap back key with:

function trapForBackKey()
{
blackberry.system.event.onHardwareKey(blackberry.system.event.KEY_BACK, handleBack);
}