How can I prevent default behavior on boxee back/menu button?

266 Views Asked by At

I have a boxee html application. I can handle all navigation keys on the remote control, except the big back/menu button. This one closes the app - I would like to use it to bring up my app menu instead.

Is there a way to prevent default behavior on this key?

2

There are 2 best solutions below

0
On

Backspace handling

document.body.onkeypress = function (e) {
    if (!e) 
        var e = window.event;

    /*backspace*/
    if(e.keyCode == 4){
       e.preventDefault();
       /*Do your thing*/
    }
}

On right click

document.onmousedown = function(e) {
    if (!e) 
        var e = window.event;

    /*right mouse*/
    if (e.which == 3){ 
        e.preventDefault();
        /*Do your thing*/
    }
}

Good article on similar event management http://www.quirksmode.org/js/events_properties.html

Edit: I'd recommend localising the onmousedown to the objects which you want to trigger the event on.

1
On

you can trigger your back/menu button since the last api update from boxee. in your js-file where you set your keyboard mode you can catch your back button with:

boxee.onKeyboardKeyBack = function(){ 
    browser.execute( "callYourShowMenuFunction()" );
}

browser.execute() delegates that to your htmlbrowser. now your backbutton should trigger your function in javascript!

remember back button usually should close the app, so don t forget to give your user an logout option ;) otherwise your app won t be published!