Sub Class_Globals
    Private intrdbSelected As Int
End Sub
Sub AddKeyPressedListener
    Dim r As Reflector
    r.Target = Root
    r.AddEventFilter("keypressed", "javafx.scene.input.KeyEvent.ANY")
End Sub
Sub KeyPressed_Filter (e As Event)
  
    Dim jo As JavaObject = e
    Dim EventType As String = jo.RunMethodJO("getEventType", Null).RunMethod("getName", Null)
    If EventType = "KEY_PRESSED" Then
        Dim keycode As String = jo.RunMethod("getCode", Null)
          
        Select keycode
            Case "UP"
                intrdbSelected = intrdbSelected - 1             'intrdbSelected is a global variable to memorize the present position of selector cursor
                If intrdbSelected <= 0 Or intrdbSelected >= 5 Then
                    intrdbSelected = 4
                End If
                Wait For (GetTagOfB4XRadioButtonToBeSelected(intrdbSelected)) Complete (myResultString As String)
                rdbSelect(myResultString)
            Case "DOWN"
                intrdbSelected = intrdbSelected + 1
                If intrdbSelected <= 1 Or intrdbSelected >= 5 Then
                    intrdbSelected = 1
                End If
                Wait For (GetTagOfB4XRadioButtonToBeSelected(intrdbSelected)) Complete (myResultString As String)
                rdbSelect(myResultString)
        End Select
    End If
End Sub
Private Sub GetTagOfB4XRadioButtonToBeSelected(myInt As Int) As ResumableSub
'With this sub we get the tag of B4XRadioButton that will be selected
    Private myString As String
   
    Try
        If 1 = myInt Then
            myString = "B4XRadioButton1"
        Else If 2 = myInt Then
            myString = "B4XRadioButton2"
        Else If 3 = myInt Then
            myString = "B4XRadioButton3"
        Else If 4 = myInt Then
            myString = "B4XRadioButton4"
        End If
    Catch
        Log(LastException)
    End Try
   
    Return myString
End Sub
Private Sub rdbSelect(myString As String)
    DecolorizeRadioButtons
    For Each vw As B4XView In Root.GetAllViewsRecursive
        If vw.tag Is B4XRadioButton Then
            Private rdb As B4XRadioButton = vw.Tag
            Try
                If rdb.Tag = myString  Then
                    rdb.mBase.SetColorAndBorder(xui.Color_Transparent, 5dip, xui.Color_White, 5dip)
                End If
            Catch
                Log(LastException)
            End Try
        End If
    Next
End Sub
Private Sub DecolorizeRadioButtons
   
        B4XRadioButton1.mBase.SetColorAndBorder(xui.Color_Transparent, 1dip, xui.Color_LightGray, 5dip)
        B4XRadioButton2.mBase.SetColorAndBorder(xui.Color_Transparent, 1dip, xui.Color_LightGray, 5dip)
        B4XRadioButton3.mBase.SetColorAndBorder(xui.Color_Transparent, 1dip, xui.Color_LightGray, 5dip)
        B4XRadioButton4.mBase.SetColorAndBorder(xui.Color_Transparent, 1dip, xui.Color_LightGray, 5dip)
   
End Sub