Results 1 to 8 of 8

Thread: int value of shift?

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    int value of shift?

    Does anyone know what the integer value of shift is?

    Code:
     char keytyped = ke.getKeyChar();
     if(Character.getNumericValue(keytyped) == ???){
         //...........
      }

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  3. #3

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    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);

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  5. #5

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    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}}}

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  7. #7

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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
  •  



Click Here to Expand Forum to Full Width