Android Code Snippet cKeyCodes

Robert Valentino

Well-Known Member
Licensed User
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

Last edited:
Top