I’m trying to make a chat rendering the user input using Graphics2D. For this, i need to get the raw (every character or letter the user types on his keyboard) user input to a String.
Currently i’m using
if (input.isKeyPressed(input.KEY_A)) {
this.text += "a";
}
However, this requires me to register every key (and some characters are not available).
How do i get the raw input to a String?
Edit: I’m using the Slick2d library
I don’t know which library you are using right now, but in Java Swing you can use:
The idea is that you should “listen” to key events, instead of checking continuously if one of the key’s is pressed. Try to find out how to do that, using the library you are using.