[Resolved] How to trap back key without trapping volume keys?

People were upset that back key quit the application instead of going back one screen…

I fixed that =D

Now they are upset that the volume keys do not work :frowning: [import]uid: 142895 topic_id: 29606 reply_id: 329606[/import]

Do you do “return false” for all keys exept the
the back key? [import]uid: 53069 topic_id: 29606 reply_id: 119005[/import]

I always return true…

Thanks :slight_smile: [import]uid: 142895 topic_id: 29606 reply_id: 119048[/import]

I’m glad I could help :slight_smile: [import]uid: 53069 topic_id: 29606 reply_id: 119065[/import]

function onKeyEvent( event )

if (event.phase == “down”) and (event.keyName == “back”) then
–do nthng
end

return true
end
Runtime:addEventListener( “key”, onKeyEvent )

volume key dsnt work…what should I do then?..
I dint got what you said above…!!:frowning: [import]uid: 148046 topic_id: 29606 reply_id: 125055[/import]

the idea is to return true for everything you decide to handle and return false on the rest so devault behavior kicks in so something like:

[code]
function onKeyEvent( event )

if (event.phase == “down”) and (event.keyName == “back”) then

–do nthng

– handle the back key here and returning true to show it
return true

end

–using the default behavior for the rest by returning false
return false

end

Runtime:addEventListener( “key”, onKeyEvent )

[/code] [import]uid: 53069 topic_id: 29606 reply_id: 125097[/import]

understood…!!
Thanks…:slight_smile: [import]uid: 148046 topic_id: 29606 reply_id: 125117[/import]

no problem :slight_smile: [import]uid: 53069 topic_id: 29606 reply_id: 125170[/import]

function onKeyEvent( event )

if (event.phase == “down”) and (event.keyName == “back”) then
–do nthng
end

return true
end
Runtime:addEventListener( “key”, onKeyEvent )

volume key dsnt work…what should I do then?..
I dint got what you said above…!!:frowning: [import]uid: 148046 topic_id: 29606 reply_id: 125055[/import]

the idea is to return true for everything you decide to handle and return false on the rest so devault behavior kicks in so something like:

[code]
function onKeyEvent( event )

if (event.phase == “down”) and (event.keyName == “back”) then

–do nthng

– handle the back key here and returning true to show it
return true

end

–using the default behavior for the rest by returning false
return false

end

Runtime:addEventListener( “key”, onKeyEvent )

[/code] [import]uid: 53069 topic_id: 29606 reply_id: 125097[/import]

understood…!!
Thanks…:slight_smile: [import]uid: 148046 topic_id: 29606 reply_id: 125117[/import]

no problem :slight_smile: [import]uid: 53069 topic_id: 29606 reply_id: 125170[/import]