Android Code Snippet cKeyCodes

I got tired of looking up the value for KeyCode when pressed so I wrote a class cKeyCodes

Hope this saves someone sometime not having to look up the code values


B4X:
Sub Process_Globals
       Public  KeyCodesDescriptions                                 As cKeyCodes
end sub

Sub Activity_Create(FirstTime As Boolean)
        KeyCodesDescriptions.Initialize
End Sub


Public Sub KeyPress(KeyCode As Int) As Boolean


   ToastMessageShow("KeyCodes:" &KeyCodesDescriptions.GetSKDKeyCode(KeyCode), False)

    If KeyCode = KeyCodes.KEYCODE_MEDIA_STOP Then
       Return False
    End If

    If KeyCode = KeyCodes.KEYCODE_POWER Then Log("PowerButton")
End Sub

Realized I posted the WRONG ToastMessageShow. Sometimes I am such a Bozo
 

Attachments

  • cKeyCodes.bas
    32.5 KB · Views: 411
Last edited:
Top