Results 1 to 7 of 7
Like Tree1Likes
  • 1 Post By doWhile

Thread: Char to keycode=not working?

  1. #1
    maximumtech is offline Member
    Join Date
    May 2012
    Posts
    4
    Rep Power
    0

    Default Char to keycode=not working?

    Here's my code:

    if(deli.length() == 1) {
    char tmp1 = deli.charAt(0);
    int tmp2 = tmp1;
    system.out.println("The keycode for "+deli+" is: "+ Integer.toString(tmp2));
    }else{
    system.out.println("Invalid amount of characters.");
    }

    It gives me a keycode but, it's not what the right keycode, for instance, I need Z to be 44, but it gives me 90. I get the 44 from using LWJGL's Keyboard.KEY_Z variable.
    I can't figure it out for the life of me.
    Help?

    NOTE* this is for a game mod, that why it has LWJGL.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,300
    Rep Power
    20

    Default Re: Char to keycode=not working?

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,300
    Rep Power
    20

    Default Re: Char to keycode=not working?

    The Java char type is an integral type. The integer value of 'Z' is 90.

    If you need to get 44, just subtract 46.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    maximumtech is offline Member
    Join Date
    May 2012
    Posts
    4
    Rep Power
    0

    Default Re: Char to keycode=not working?

    I almost put it in there but, I decided not to, I tested with other characters, and the values are all different.

  5. #5
    maximumtech is offline Member
    Join Date
    May 2012
    Posts
    4
    Rep Power
    0

    Default Re: Char to keycode=not working?

    Upon further research, 44 is the linux keycode for Z, but I'm on windows, how would i convert the keycodes over?

  6. #6
    maximumtech is offline Member
    Join Date
    May 2012
    Posts
    4
    Rep Power
    0

    Default Get linux keycodes from Char?

    Keycode Table
    I need those, for instance, Z is 44 there, but using conventional methods, I get 90, which is windows. Help? This is very urgent for me, no one on skype, or another forum can help me.

  7. #7
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: Char to keycode=not working?

    Please keep the discussion on this topic to this post, as opposed to starting another thread on the exact same topic. I've merged the threads
    DarrylBurke likes this.

Similar Threads

  1. "boolean isDigit(char ch)" not working...please help
    By cc11rocks in forum New To Java
    Replies: 7
    Last Post: 02-06-2011, 01:40 AM
  2. How can I supress keycode?
    By cjmartin in forum AWT / Swing
    Replies: 7
    Last Post: 08-06-2010, 06:00 PM
  3. replaceALL(char oldChar, char newChar) method
    By arson09 in forum New To Java
    Replies: 0
    Last Post: 04-28-2010, 05:48 AM
  4. Different keycode values
    By dswastik in forum CLDC and MIDP
    Replies: 0
    Last Post: 01-29-2009, 03:44 PM
  5. drawing char by char with Graphics
    By diggitydoggz in forum New To Java
    Replies: 5
    Last Post: 12-27-2008, 12:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •