Input handler ignores presses of spacebar

OK, I’m hoping I’ve done something stupid that will eat five minutes and a good chunk of ego. I’ve got an input manager with various forms of input (see code), including the spacebar, and an input listener. For some reason, only lifting the spacebar registers. Pressing the spacebar gets no result.

[java]
public void setUpKeys()
{
inputManager.addMapping(“Foreward”, new KeyTrigger(KeyInput.KEY_W));
inputManager.addMapping(“Left”, new KeyTrigger(KeyInput.KEY_A));
inputManager.addMapping(“Right”, new KeyTrigger(KeyInput.KEY_D));
inputManager.addMapping(“Back”, new KeyTrigger(KeyInput.KEY_S));
inputManager.addMapping(“Jump”, new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addMapping(“Shoot”, new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addMapping(“Remove”, new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));

    inputManager.addListener(keyboardActions, "Remove");
    inputManager.addListener(keyboardActions, "Foreward");
    inputManager.addListener(keyboardActions, "Left");
    inputManager.addListener(keyboardActions, "Right");
    inputManager.addListener(keyboardActions, "Back");
    inputManager.addListener(keyboardActions, "Jump");
    inputManager.addListener(keyboardActions, "Shoot");
}

private ActionListener keyboardActions = new ActionListener()
{
    public void onAction(String name, boolean keyPressed, float tpf)
    {
        if(name.equals("Foreward"))
        {
            up = keyPressed;
        }
        if(name.equals("Left"))
        {
            left = keyPressed;
        }
        if(name.equals("Right"))
        {
            right = keyPressed;
        }
        if(name.equals("Back"))
        {
            down = keyPressed;
        }
        if(name.equals("Jump"))
        {
             player.jump();
             System.out.println(keyPressed);
        }

};
[/java]
Basically, my output goes like this:
false
false
false
false

if I hi the spacebar four times.

Any ideas?

Are you running nifty GUI? Something else must be grabbing the event, I guess. Space bar normally works fine.

1 Like

Ooh, I am. Uh, how do I stop nifty from eating it? I’d like to do so without just clearing all the default inputs, I need esc-quits the program and a couple others for now…

@ulfgur said: Ooh, I am. Uh, how do I stop nifty from eating it? I'd like to do so without just clearing all the default inputs, I need esc-quits the program and a couple others for now...

I have no idea. It’s been two years or so since I touched anything related to nifty.

Clearing all of the defaults wouldn’t help anyway because nifty isn’t using that kind of mapping.

Got it! (for those of you who care, I used the following:

nifty.setIgnoreKeyboardEvents(true);
)

Thanks!