[Solved] How do I disable the spacebar completely?


I’m currently trying to disable the spacebar completely. I don’t want anything to happen when it gets pressed, but something happens anyway and I can’t find out what is listening to it. I have flyCam disabled and I’m not using Nifty (I am using tonegodgui though. Loving it).

What it does right now is it seems to be “refreshing” the screen. It used to just duplicate every spatial on the screen but now it just crashes the game (I assume because it’s duplicating tonegodgui panels and that’s bad).

inputManager.clearMappings() and nifty.setIgnoreKeyboardEvents(true) are not working.

Thanks in advance

My guess is a rawinputlistener somewhere.

At least jme does not do anything like this by default, so it must be your code.

Thanks for replying, unfortunately I didn’t assign the spacebar to anything. I set up the WASD and 4 arrow keys, i,o,p,g, and h plus whatever jme has on default.

As far as I’m aware, the only actions I did that may have changed bindings was disable the flyCam and make a new Screen for tonegodgui (which employs some clickable buttons but they only listen to mouse events, not the spacebar?)

At least my jme version from github does not do anything in spacebar presses

Repeating: JME doesn’t do anything by default with the spacebar. So it has to be something you’ve added… like a tonegodgui screen that would want to use the spacebar to press buttons and stuff.

So this isn’t really a JME question but a tonegodgui question… presuming you really don’t have your own RawInputListener registered.

Thanks for the pointers guys. After doing some thorough digging around in the source I found a possible cause for the trouble:

// Default keyboard interaction @Override public void onKeyPress(KeyInputEvent evt) { if (evt.getKeyCode() == KeyInput.KEY_SPACE) { onMouseLeftPressed(new MouseButtonEvent(0,true,0,0)); } } located in the Button class

So I went back, made my own button class that got rid of this behavior and now the spacebar does nothing. I’ve been sitting on this bug for over a month. :smile:

I’ll mark this as solved and stick it in the tonegodgui subtopic. Thanks again!

Just want to let you know, that according to the Docs, you’re supposed to change “Button” to “ButtonAdapter” after implementing all of the methods you want to use, since Button is Abstract.


ButtonAdapter Class

Tips for using the Button class
Create a button
Implement all abstract methods
Write your code for the event handlers you wish to use
Change the Button to a ButtonAdapter
Remove all unused event handler methods


Notice the “ButtonAdapter” DOES NOT have any key events with SPACE.

Not too sure why that’s there, but w/e lol. Weird that there is 2 classes for Buttons, but it works so w/e…

You could still use your custom Button Class, but figured this would help you out :).

I did use ButtonAdapter originally actually. That’s why I had this bug. Since it inherited the space event handler from Button, I thought I had to override Button first and then copy everything over from ButtonAdapter.

I don’t have my code in front of me right now but whatever I did worked. :slight_smile:

Didn’t notice the extends, sorry about that…

Hmm weird… Hopefully tone will do something about it, but couldn’t you override the method?

Either way, feel useless now hahha…

Have a good day.