[SOLVED] How to react differently to lower and upper case input letters?


I’m converting a “Processing” demo to JME. I now got to the input handling.

In Processing, I could react differently to ‘r’ (more RED) and ‘R’ (less RED).

How do I do that in JME? There is only “KeyInput.KEY_R” but not “KeyInput.KEY_r” …

You have to check for the shift key like you do for the others and keep its state (pressed/released).
Then when the R key is entered, check if the shift key is pressed or released.

That’s not very convenient I reckon, but it can easily be warped in a more general input class.

In a RawInputListener you can actually get the typed character. So you can see ‘r’ versus ‘R’. But then you have to handle all dispatch yourself.

This reminds me that I should really post my InputMapper wrapper for InputManager. It supports such key combinations. It knows the difference between shift, r, and shift+r, etc… and can have different triggers attached to any of them.

1 Like