Convert NSString to KeyCode.

Discussion in 'Mac Programming' started by DeDMakar, Apr 12, 2008.

  1. macrumors member

    Joined:
    Mar 24, 2008
    #1
    I use function CGPostKeyboardEvent for Keyboard Event. I need to convert NSString in KeyCode. What offers?
     
  2. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Are you trying to convert it to a CGKeyCode? CGKeyCode is just an unsigned short essentially, so NSString's intValue may work (typecasted of course), but it depends what the NSString value is. Can you give an example?
     
  3. thread starter macrumors member

    Joined:
    Mar 24, 2008
    #3
    I have a variable of type NSString *sStr = "password". Each letter I enter by means of CGPostKeyboardEvent. The letter "p" and following must to convert in CGKeyCode.
     
  4. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
  5. thread starter macrumors member

    Joined:
    Mar 24, 2008
    #5
    If there are no other variants, it is necessary to use this simple function keyCodeForKeyString.:rolleyes: Thank!!!
     
  6. thread starter macrumors member

    Joined:
    Mar 24, 2008
    #6
    HI!!!
    What CGKeyCode do the capital letters have?
     

Share This Page