Does anyone know what the integer value of shift is?
Code:char keytyped = ke.getKeyChar();
if(Character.getNumericValue(keytyped) == ???){
//...........
}
Printable View
Does anyone know what the integer value of shift is?
Code:char keytyped = ke.getKeyChar();
if(Character.getNumericValue(keytyped) == ???){
//...........
}
Isn't there a VK_* list somewhere in the SDK docs?
Im using an old C++ book to look up the ASCII character encodings. For some reason
was printing -1 when the Backspace key was pressed but by casting the char to an int a numeric value of eight is printed.Code:System.out.println(Character.getNumericValue(keytyped));
Code:char keytyped = ke.getKeyChar();
int i = keytyped;
System.out.println(i);
Character.getNumericValue returns -1 for every character except '0' through '9' and other numeric signs considering the UNICODE character set.
So it is used for string -> number conversion.
I'm not sure, it might even return 1 for I, 5 for V etc (roman numbers).
To get the UNICODE code of a character:
int code = (int)my_character;
Don't forget that char is a UNICODE character in Java.
Dam that's weird. I probably should have used another method in the Character class. :D
Implicit widening conversion no cast needed.Code:int code = (int)my_character;
I just had to say that. :D {{{laughing}}}
I wasn't sure. I'm never sure with casts between primitive types in Java. I simply do all casts explicitly, it's just easier to see that there is a cast.
Just busting your chops. Explicit casting is always better than implicit that's for sure. :D
Didn't see the last line of your post.