B4J Question Capture KEY_PRESSED event


Active Member
Licensed User
I 'm using the following piece of code.

Dim r As Reflector
r.Target = MazinForm.RootPane
r.AddEventHandler("KeyDown", "javafx.scene.input.KeyEvent.KEY_PRESSED")

Key press/release handling routines:
Sub KeyDown_Event(e As Event)
    Dim r As Reflector
    r.Target = e
    Dim keycode As String = r.RunMethod("getText")
    'ShowToast(keycode & " pressed")
    Select Case keycode.ToLowerCase
        Case "m"
            ' do something here

        Case " "
           ' do something here
    End Select
End Sub
I have two issues:
1. The code for the "m" key press work as expected, but for the SPACE key don't.
2. Event is not consumed and because of this, the button from the interface with focus is pressed when pressing SPACE.

What can I do to consume the event?

Thank you.