api.addEventListener({ name: ‘keyback‘ }, function(ret, err) { if (flag == 1) { api.closeWidget({ silent: true }); } else { flag = 1; api.toast({ msg: ‘再点一次退出应用‘, duration: 2000, location: ‘bottom‘ }); setTimeout(function() { flag = 0; }, 2000); } });