Hi, is it possible to tell what keys coming from LWJGL input are printable
characters (not alt/ctrl/shift/pause/F1/F2 etc.)?
The next best thing to trying to get advice from here that I could think of
is a large switch statement with all Keyboard.KEY_ constants...
I'm not sure if there is an easy way of doing it, but I think you can just use ranges of values (like 'a' to 'z', 'A' to 'Z', etc.) to simplify it a little bit.
You might be able to do Keyboard.getEventCharacter() to see if it is printable (i.e. if it actually returns a char), but I'm not sure of that.
Someone else can chime in here :lol:
Thanks for your reply. I solved it with a big hammer, something like this:
public class KeyFilterPrintable implements KeyFilter {
private static String validCharacters =
"`1234567890!{}:|!?abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
public boolean isValidKey( int key, char character ) {
return validCharacters.indexOf( character ) != -1;
}
}
And I pass the result of Keyboard.getEventCharacter() as the second parameter to isValidKey.
Well, definitly better than a big switch statement. :lol:
Gonna have to remember this when I need it later (if you don't mind me stealing you're ideas) :D
Quote from: "Fool Running"[...]
You might be able to do Keyboard.getEventCharacter() to see if it is printable (i.e. if it actually returns a char), but I'm not sure of that.
[...]
Yea, it should return Keyboard.CHAR_NONE in those non printable cases.