B4J Question Why is Button key press sensitive ?


Active Member
Licensed User
I have a B4J program with a button added using Designer.
The button just has the text label "+"

When I run the program and press the SPACE key, the CLICK event for this button is executed.

How do I remove the keyboard sensitivity from this button.

I have NOT assign a key listener to the button.
Looking online I see the object InputMap for jButtons, and
an InputMap has a Clear function.

I tried writing this function.

Public Sub ClearButtonKeypresses(ThisButton As Button)
    Private nativeMe As JavaObject=Me
End Sub

#if JAVA
import javax.swing.InputMap;
import javax.swing.JButton;

public void clearButtonInputMap(JButton button) throws Exception 
    InputMap inputMap = button.getInputMap();
#end if

When I pass the B4j Button to the Java code I get...

java.lang.RuntimeException: Method: clearButtonInputMap not matched.

I would welcome any helps resolving this, or
another method of clearing any associated keys from a button.


Licensed User
Any node that has focus will trigger either with space key, enter key and some will also capture pageup/down and backspace.

In the click event you will need to try to find how this event was triggered
Last edited:
Upvote 0


Well-Known Member
Licensed User
Use the MouseClicked event
Sub yourButton_MouseClicked (EventData As MouseEvent)
Then it wont trigger on anything other than a mouse click on the button.

(Also a Button in a B4J UI program is not a jButton)
Upvote 0