Sub Activity_KeyPress (KeyCode As Int) As Boolean ' Return true to consume the event
If KeyCode = 4 Then ' Back button
' -- do something here --
Return True ' Consume event, so the app does not close
Else
Return False ' Do not consume, the app will close or go to previous activity
End If
End Sub