构建Cordova应用程序并在Windows上进行测试 . 在我的Windows手机上,硬件后退按钮不会触发Cordova的后退按钮事件 .

我已经尝试了多种方法来捕获事件,但到目前为止还没有成功 . 有人得到答案吗?

目前我的代码是这样的:

function onDeviceReady() {
// This is supposed to capture the WinJS onbackclick event.
if (WinJS) {
    WinJS.Application.onbackclick = function(e) {
        MyApp.app.navigationManager.back();
        // Return true otherwise it will close app.
        return true;
    }

}

function goBack(event) {
    // Here I handle going back
}
// This is how Cordova says you can listen to the event
document.addEventListener("backbutton", goBack(event), false);

// This is another method using a different method to try to capture the event
if (cordova.platformId == 'windows') {
    Windows.Phone.UI.Input.HardwareButtons.addEventListener("backpressed", goBack(event));
}
};

这些都不是捕获事件:应用程序总是暂停而不是返回上一页 .