Back button event

Are any way to change back button in function onKeyReleased( evt ) ?
  • function onKeyReleased( evt ) {
    if ((keyPressedTime > 0) && (evt.getKey() == Ui.KEY_ESC)) {
    var delta = System.getTimer() - keyPressedTime; // ms since last press
    keyPressedTime = 0;
    if (delta > 1000) {

    a=2;


    } else {

    a=1;
    }
    return true;
    }
    }
  • I'm not sure what device you're hoping to deploy on, but it seems that you've missed my comments above...

    There is an issue on many devices where the onKeyReleased() function isn't called, so you won't be able to implement normal key hold behavior. You can see this post for more information.


    The onKeyReleased() function is only called on some devices (I believe the vivoactive is the only one). If this is never called, a will never get changed.

    Even if it is called, I'm fairly certain that it isn't working the way that you want. I believe that onKeyPressed() is called first and immediately after onBack() is called. This happens before the key is released. Finally, when the key is released onKeyReleased() is called. This means that anything you do in onKeyReleased() won't take effect for the onBack() call (since the onBack() call happens before onKeyReleased()).

    Travis