Jump to content

Is overriding hardware back button good practice?


ogramp
 Share

Recommended Posts

Hello.

Is it good practice to override hardware back button on a mobile device if the game is a web game played from a web browser, not a native app? Seems like a wrong thing to change the default expected behavior of a browser app. Actually, is it even possible? Maybe it's not. Has anyone tried doing this kind of thing?

(I was thinking of making a pause menu appear in a Snake game if I pressed the hardware back button on my phone or tablet)

Link to comment
Share on other sites

When the browser loads a new url it pushes it on to a stack, all the back button does is pop the current state off and load the last state it finds, its all detailed in the history api, and support is ubiquitous for new browsers.

A general rule of thumb is that it isn't a good idea to muck with it too muck, its inclusion was pushed along by side page apps mocking multiple page apps so that the back button behaviour remains consistent with what a user expects, for gaming, the 'normal' webpage flow is changed anyway so you have more leeway to change standard behaviours.

You could wire it up so that a back event pushes your app into it's pause state, but, I don't think you could stop people from hitting back again, which would eventually get out of your app.

You can't stop people navigating away from your site, for very good reasons. You do have a small window before the browser updates to the new page though, any synchronous process will run (not sure if there is a time limit, might be), if your app is set up for it you could save the current app state somewhere (even locally) and when they next hit your URL fire up your app using that state and stick it into pause.

Link to comment
Share on other sites

And the correct answer is: "It is bad practice to mess with the hardware BACK button on mobile devices in Phaser games". Thank you all for participating in this survey and please help yourself yourself to a nice gift basket on your way out. :D

But in all seriousness, I did some more reading and agree with mattstyles, it's not a good idea, messing with the back button on mobile devices. Even if it is possible. And VitaZheltyakov, I think windows phone (i don't have other, don't judge!) is the same way.

Tnx for thinking along!

Link to comment
Share on other sites

I use the back button to get to previous screen/state of the app or a web-app. If there is a software back button somewhere on the screen, I expect the hardware-back to do the same thing as the software-back does.  Domains and urls don't matter. 

I think you should override it to take the user back to the main menu/title screen, if your game has one, and maybe have a "resume game" button there.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...