Android Back Button with Director issue

Hello everyone! The following code I use on two connecting screens. If I press the Android “back” button right when the scene changes it loads both screens! Has to be a PERFECT click though. Is there a way to delay this function on the second screen so my game has a second to dump the previous screen stuff? Can a global Runtime listener be delayed? Here is my code/ansca sample code:

[lua]local function onKeyEvent( event )
local returnValue = true

local phase = event.phase
local keyName = event.keyName

– Make an exception for Volume Up key and default to it’s normal function (just for show)
if “volumeUp” == keyName then
returnValue = false – use default key operation
end

if “volumeDown” == keyName then
returnValue = false – use default key operation
end

if “back” == keyName then
director:changeScene( “loadback” )
end

– we handled the event, so return true.
– for default behavior, return false.
return returnValue
end

– Add the key callback
Runtime:addEventListener( “key”, onKeyEvent );[/lua]

Thanks for any help! [import]uid: 46082 topic_id: 34680 reply_id: 334680[/import]

I’m at work, so I can’t test this. Anyone know if something like this would work? Setting a delay on a function with a Runtime listener?
[lua]local function onKeyEvent ( event)
local returnValue = true
local phase = event.phase
local keyName = event.keyName
if “volumeUp” == keyName then
returnValue = false
end
if “volumeDown == keyName then
returnValue = false
end
if “back” == keyName then
director:changeScene( “loadback” )
end
return returnValue
end
local function startListener()
Runtime:addEventListener( “key”, onKeyEvent )
end

timer.performWithDelay( 2000, startListener) [/lua] [import]uid: 46082 topic_id: 34680 reply_id: 137880[/import]

I’m at work, so I can’t test this. Anyone know if something like this would work? Setting a delay on a function with a Runtime listener?
[lua]local function onKeyEvent ( event)
local returnValue = true
local phase = event.phase
local keyName = event.keyName
if “volumeUp” == keyName then
returnValue = false
end
if “volumeDown == keyName then
returnValue = false
end
if “back” == keyName then
director:changeScene( “loadback” )
end
return returnValue
end
local function startListener()
Runtime:addEventListener( “key”, onKeyEvent )
end

timer.performWithDelay( 2000, startListener) [/lua] [import]uid: 46082 topic_id: 34680 reply_id: 137880[/import]