### Intercept Key Pressed

Example of intercepting a key pressed for a MainForm.
When a key is pressed, the key code is checked and action taken accordingly.
For this example, key F1 is intercepted.
External libraries required: jReflection, JavaObject.
Reference: https://docs.oracle.com/javase/8/javafx/api/javafx/scene/input/KeyEvent.html
`Sub AppStart (Form1 As Form, Args() As String)
...
'Define the key event filter which uses the Key_Filter event.
Dim r As Reflector
r.Target = MainForm.RootPane
r.AddEventFilter("Key", "javafx.scene.input.KeyEvent.KEY_PRESSED")
End Sub`
'Key filter event handling key code F1
`Sub Key_Filter (EventData As Event)
Dim joEvent As JavaObject = EventData
Dim keycode As String = joEvent.RunMethod("getCode", Null)
If keycode = "F1" Then
mnuHelp_Action
EventData.Consume
End If
End Sub`
`Sub mnuHelp_Action
fx.Msgbox(MainForm, "Key F1 pressed for help.", "Help")
End Sub`

Changed: , Category: Forms, File: T6C195M1421.htm, ID: 1421