I’m trying to capture the BACK key on the Android and have it control navigation, but I’m running into some issues. It SEEMS to work… but it takes me back to the main menu and then exits the app. I just want it to take me back to the previous screen - in this case the main menu - which I am controlling manually.
It’s almost as if it handles the key press… gets back to the main menu… then handles it again from the main menu and closes the app.
I have no handler at the moment in the main menu, but here is the code from the previous screen.
onHardwareKeyEvent = function( event ) local returnValue = false -- use default key operation local phase = event.phase local keyName = event.keyName if ( phase == "up" and keyName=="back" ) then if (ShowingDoc == false) then -- not showing a document so go to menu Runetime:removeEventListener( "key", onHardwareKeyEvent ) storyboard.gotoScene( "scene\_menu" ) else -- showing a document so kill it webView:removeSelf() webView = nil topText.text = "Protocols" topText.size = 18 ShowingDoc = false end end return returnValue end Runtime:addEventListener( "key", onHardwareKeyEvent )