Event listner wont remove

Umm I suppose I could…never really thought about that. Is there an easy way to get what scene is loaded in corona other then setting it insde a var myself?

storyboard.getCurrentSceneName() see:

http://docs.coronalabs.com/api/library/storyboard/getCurrentSceneName.html

Unless you need the keyboard handler to do something different each scene (beyond specifying a different scene name to go back to), then it make sense to put it in each scene.  In programming there is a principle called the DRY principle.  Don’t repeat yourself.  if you have 30 scenes and you have to write that back handler 30 times, that’s a lot of work. 

What I would more likely do is put it all in main.lua and then in each scene, during the enterScene() function, set a variable that can be seen from main.lua (yea, it begs for a global, but wait!)   like adding a variable to the storyboard table called .goBackTo

So if your in level1.lua and the back button should take you back to menu.lua then do:

storyboard.goBackTo = “menu”

Then in your one function in main.lua you can say if the back button was hit, storyboard.gotoScene(storyboard.goBackTo)

Easy as pie.

Yeah that makes a lot of sense…I have a hard time with lua/corona with scope issues and trying to find code sometimes. I’ve developed a place all the code in 1 file per scene approach and if I need it more then once make it a class. It may not be the best approach but it’s helped me keep everything in place. I should rethink that approach though as I can see what you’re talking about.

P.S. moving it to the main.lua worked just fine