Search code examples
androidgame-maker

How do I close a GameMaker game by pressing the back button on an Android device?


Is there a way to close the game by pressing the back button on an Android device?

I haven't been able to get it to work.


Solution

  • On mobile devices, the back button is mapped to the keyboard backspace, vk_backspace, which can be used like this:

    if (keyboard_check_pressed(vk_backspace)) {
        game_end();
    }
    

    From the manual: https://docs2.yoyogames.com/source/_build/3_scripting/4_gml_reference/controls/device%20input/index.html