Sub Globals
Dim KeyCode_Back_Pressed As Boolean
Dim KeyCode_Back_Time As Long
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'return true if you want to consume the event
Select Case Keycode
Case KeyCodes.KEYCODE_BACK
If KeyCode_Back_Pressed = True Then 'Back Key was already pressed
If DateTime.Now - KeyCode_Back_Time > 2000 Then 'Interval too long
KeyCode_Back_Pressed = False 'Expired
End If
End If
If KeyCode_Back_Pressed = False Then 'User presses Key_Back for the first Time
ToastMessageShow("Press again to finish",False) 'Show Toastmessage
KeyCode_Back_Pressed = True 'Remember Keystroke
KeyCode_Back_Time=DateTime.Now 'Store Time
Return True 'Consume the Event to prevent Application from Closing
Else
'Do not consume and let User exit Application
End If
Case Else
End Select
End Sub