|
-
Jul 8th, 2003, 02:46 PM
#1
Thread Starter
Dazed Member
int value of shift?
Does anyone know what the integer value of shift is?
Code:
char keytyped = ke.getKeyChar();
if(Character.getNumericValue(keytyped) == ???){
//...........
}
-
Jul 9th, 2003, 01:49 AM
#2
Isn't there a VK_* list somewhere in the SDK docs?
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 17th, 2003, 02:44 PM
#3
Thread Starter
Dazed Member
Im using an old C++ book to look up the ASCII character encodings. For some reason
Code:
System.out.println(Character.getNumericValue(keytyped));
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:
char keytyped = ke.getKeyChar();
int i = keytyped;
System.out.println(i);
-
Jul 17th, 2003, 03:51 PM
#4
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.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 17th, 2003, 10:08 PM
#5
Thread Starter
Dazed Member
Dam that's weird. I probably should have used another method in the Character class.
Code:
int code = (int)my_character;
Implicit widening conversion no cast needed.
I just had to say that. {{{laughing}}}
-
Jul 18th, 2003, 01:59 AM
#6
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.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jul 18th, 2003, 10:25 PM
#7
Thread Starter
Dazed Member
Just busting your chops. Explicit casting is always better than implicit that's for sure.
-
Jul 19th, 2003, 04:15 AM
#8
Didn't see the last line of your post.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|