I use this code to detect key pressing, but i can not catch "enter" and "space"
Is there a way to catch this two keys?
B4X:
Sub AddKeyPressedListener
Dim r As Reflector
r.Target = MainForm.RootPane
r.AddEventHandler("keypressed", "javafx.scene.input.KeyEvent.KEY_PRESSED")
End Sub
Sub KeyPressed_Event (e As Event)
Dim jo As JavaObject = e
Dim keycode As String = jo.RunMethod("getCode", Null)
If keycode = "CONTROL" Then
keyb_on
End If
Log("keycode: " & keycode) ' No log if "Space" or "Enter" key is pressed
If pnlKeyboard.Visible Then
If keycode = "BACK_SPACE" Then
If lblResult.Text.Length > 0 Then
lblResult.Text = lblResult.Text.SubString2(0, lblResult.Text.Length - 1)
Dim prt As String = lblResult.Tag
prt = prt.SubString2(0, prt.Length - 1)
lblResult.Tag = prt
End If
Else If keycode.IndexOf("NUMPAD") >= 0 Then
lblResult.Tag = lblResult.Tag & keycode.SubString(6)
lblResult.Text = lblResult.Text & "*"
Else If keycode = "ESCAPE" Then
lblResult.Tag = ""
lblResult.Text = ""
Else If keycode = "ENTER" Then
'Nothig is happening here, never goes here
ProcAct
Else If keycode = "ALT_GRAPH" Then
ProcSet
End If
End If
End Sub
Is there a way to catch this two keys?