# Back button exiting app when it should not

**URL:** <https://forum.webostv.developer.lge.com/t/back-button-exiting-app-when-it-should-not/10465>\
**Category:** Web App Development\
**Created:** [October 14, 2024, 5:15am UTC](https://forum.webostv.developer.lge.com/t/back-button-exiting-app-when-it-should-not/10465 "2024-10-14T05:15:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![user125](https://avatars.discourse-cdn.com/v4/letter/u/e9a140/32.png) [@user125](https://forum.webostv.developer.lge.com/u/user125)\
**Post date:** [October 14, 2024, 5:15am UTC](https://forum.webostv.developer.lge.com/t/back-button-exiting-app-when-it-should-not/10465/1 "2024-10-14T05:15:22Z")

</div>

Our app has recently started behaving differently when using the Back button on the LG remote. Previously it would only exit to LG Home using the Back button in one scenario only, and we could override this button for other parts of the app. However now, any time the Back button is pressed from the first page in the app, it will go to the LG Home screen, even though our code prevents this, and we have not made code changes recently to this behaviour.

We have the following set up in the app as defined in [https://webostv.developer.lge.com/develop/guides/back-button#implementing-the-back-button-function-to-exit-the-app](https://webostv.developer.lge.com/develop/guides/back-button#implementing-the-back-button-function-to-exit-the-app) , but can you please advise if there are any other settings or values that should be used?

- `"disableBackHistoryAPI": true` in the appinfo.json file
- `Back = 461` used as the LGRemoteKeys key code for ‘Back’
- We use window.close() to exit the app but this should only happen from one place

---

<div class="post-metadata">

**Author:** ![narae0.kim](https://avatars.discourse-cdn.com/v4/letter/n/87869e/32.png) [@narae0.kim](https://forum.webostv.developer.lge.com/u/narae0.kim)\
**Post date:** [October 17, 2024, 8:09am UTC](https://forum.webostv.developer.lge.com/t/back-button-exiting-app-when-it-should-not/10465/2 "2024-10-17T08:09:31Z")

</div>

Please check again with a simple test app like this:

```auto
// appinfo.json
{
    ...
    disableBackHistoryAPI: true;
    ...
}

// index.html
<script>
window.addEventListener("keydown", function(inEvent) {
    if (window.event) {
        keycode = inEvent.keyCode;
    } else if (e.which) {
        keycode = inEvent.which;
    }
    if (keycode === 461) { // Do nothing
      console.log(keycode);
    }
});
</script>

```
