This question already has an answer here:

I have done the same thing in android natively by simply calling onBackPressed().I've been trying to do the same thing in Unity with c#. there are classes like Input that handles inputs but does not have access to android's back button.I've also seen touch simulators and whatnots but I'm looking for something as simple as calling this.onBackPressed().Please note that I'm not looking to capture back button press, I want to press back button from my code.

marked as duplicate by Programmer c# Oct 21 at 6:55

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    I've been using this.

    if(Input.GetKeyDown(KeyCode.Escape))
    • Thanks for the reply, but I don't want to detect backpress after it happens. I'm looking to invoke pressing back button programmatically, not by user touch.– KhnshNOct 21 at 12:23
    • 1
      You can make an event event Action OnSimulateBackButtonEvent then add all necessary listeners back button methods to that event OnSimulateBackButtonEvent +=BackButtonMethod1.Then when you need to begin the simulation, just invoke the event OnSimulateBackButtonEvent.Invoke()– TrickoOct 22 at 1:08
    • @Tricko Yup, this could do the trick. tnx– KhnshNOct 23 at 7:05

    Not the answer you're looking for? Browse other questions tagged or ask your own question.