back button closing app instead of doing something else.

Hello everyone,

I tried using the back key on android to navigate to the previous screen. Its working fine except only when the soft keyboard is present. When the soft keyboard is present and I pressed the back button it first hides the soft keyboard, and when the back key is pressed again the app closes. Does anyone experience this?

Here are some of my codes.

[lua]

local function gotoBack()
    storyboard.gotoScene( “home”, “slideRight”, 200  )
end

local function onKeyEvent( event )
    local phase = event.phase
    local keyName = event.keyName
    
    if(phase == “down” and keyName == “back”) then
        gotoBack()
    end
    return true
end

Runtime:addEventListener( “key”, onKeyEvent )

[/lua]

Have you tried searching for the answer?

https://www.google.com/search?q=back+button+app+android+site%3Acoronalabs.com

Two of the first three results address your question.

Have you tried searching for the answer?

https://www.google.com/search?q=back+button+app+android+site%3Acoronalabs.com

Two of the first three results address your question.