# Why is the “back” key acting like it is pressed twice?

I want to show toast message when the user presses the back button. I am handling button using this code, which is in my Update function:

if (Input.GetKeyUp(KeyCode.Escape)) {
print ("UPUP");
ToastHelper.ShowToast ("Back", false);
//Application.Quit();
}


ToastHelper is plugin here.

The issue is that the toast message shows up twice, so it seems like the back key is acting like it was pressed twice. I only want it to execute once.

• Are you sure you're not calling that toast it somewhere else? If you're on visual-studio, can you right-click the ShowToast method and search for uses, to confirm this? – XenoRo Dec 7 '17 at 16:45
• Yes i am sure, I call it only from that place. print statement execute two times that means Back call two times – Rupal Patel Dec 7 '17 at 16:48
• @RupalPatel the sparse codesample you post seems to be using key-polling. Are you sure that you don't just keep the back key pressed long enough for your key-handler to poll twice? – dot_Sp0T Dec 7 '17 at 16:51
• Yes i am sure, i just press Escape key and release as normal not long in pc still it shows two times, And I tested in mobile device, i press single back but it executes two times. – Rupal Patel Dec 7 '17 at 16:54
• Do you maybe have that script on two different game objects? – Philipp Dec 7 '17 at 17:19