Compound inputs?

Greetings, Monkeys.

I have a little question to ask which i couldnt answer myself with neither the docu nor the search.

I want to bind compound keyinputs like Ctrl+W and stuff. So i thought about giving in something like that:

inputManager.addMapping("ShowGui", new KeyTrigger(KeyInput.KEY_LCONTROL), new KeyTrigger(KeyInput.KEY_W));

Obviously it doesnt work. It just reacts when either W or LCtrl is pressed.
So my question is, how do i achieve those "compound" key inputs? Any proper way of doing this?

With regards,
1 Like

I don’t know of any inbuilt way to handle this.

In your ActionListener onAction method I would simply set flags for which keys are depressed, then check for both the ‘W’ and ‘LCtrl’ flags before executing your code.

1 Like

I hoped to avoid such things to be honest. I thought the inputManager had some way to handle this kind of stuff.

Thanks for your answer anyway. :slight_smile: Maybe our mighty normen knows an answer later on. Ill just stick with your proposal for now until (if in case anyone knows a smoother way) i get a new answer. :smiley:

You have to do that logic yourself, you just get information about pressed or unpressed keys. Given that games can have many different input schemes that can vary widely from the normal “Modifier+Key” input and that the solution is easy to implement we think thats the best way.


Okay… So i will stick with my actual solution. Thanks, you two :slight_smile: