Sorry Jay, it’s true is this case ;).
You are correct in that scene.foo = “bar” is visible within the whole module, but that’s because scene is declared local at the top of the module making it visible to the whole module.
Runtime is a global object that’s visible from everywhere. The problem with the code above is that the *listener* is declared local inside another function, which means the reference to it will disappear as soon as the function ends. Runtime:removeEventListener() requires a reference to the listener that it should remove. Since that reference is gone (nil) when removeEventLister is called, it can’t remove the listener.
In other words, onAndroidKeyEvent is only visible in scene:create() in the code above.