So I was wondering, when using LWJGL's Keyboard class, is there a method to get a character from an int? I was thinking about something like this:
char keyF = Keyboard.getChar(Keyboard.KEY_F);
would return f
.
Is there such a method? And if so, what is it called?
NOTE I have already tried casting from int to char
There is no other way (I think) to get it other than creating a method yourself for the keys you use. For example if you only use X and Y keys, your method would look like this.
public char getChar(int code){
switch (code){
case Keyboard.KEY_X: return 'x';
case Keyboard.KEY_Y: return 'y';
}
}
But you have to create a case for each key you use.
Also see http://legacy.lwjgl.org/javadoc/org/lwjgl/input/Keyboard.html#getKeyName%28int%29 It says how to convert a int to String. You could probably use the first character of that string. Note that this would not work for keys like SHIFT, F1 etc.,