B4J Question Get Control Key State


Well-Known Member
Licensed User
Longtime User
I need to get the state of the keyboard Control Key.

Imagine an application such as:

I want to select the rectangle panes on a mouse click. If the control key is being held down I want to add the selected pane to the selected list, otherwise make the new selection the clicked pane and deselect any already selected panes - basically multi-select.

I've searched and tried several different things. I'm thinking the solution will probably involve using Javaobjects and installing an event handler.

I could then monitor the process and keep a state variable of whether the control key is up or down.

I also found the Java documentation page for a Key Event:

and I noticed there is a method "isControlDown()". This might he promising.

Is it possible to get the state or monitor the state of the Control Key?

Another question having to do with the Java FX Scene Builder. On the right-hand side, in the inspector, in the Code section, they have entries for things such as "On Key Pressed". What are these entries used for? Are they places to enter script commands? Do you put references to subroutines to handle the On Key Pressed event? What would I enter in this field in order to have it invoke a B4J subroutine to handle the On Key Pressed event?