Determine pressed keys while dragging FROM OTHER application

  • Hi,
    I need to check if a specific key is pressed while receiving a drag.
    When drags come from inside the process a keydown event is generated
    as currentEvent and I can get that but for drags from other
    applications I dont get such an event. I tried getKeys from the
    carbon layer. I tried the following category on http://
    www.ghosttiger.com/?p=136 and I can detect presses of CHARACTERS just
    fine. A b C d <<SPACE>> as the keycodes get translated to unichars
    for me.

    What I cant do is detecting arrow keys.
    The cateogry returns wrong unichar values for it.... Well all arrow
    keys translate to the same unichar for me...
    And I dont know how to interpret what getKeys tells me...... sure I
    can just take the raw codes from the KeyMap but those seem to be
    different for different keyboards. (not to mention architectures!?)

    So... how does one go about detecting these keys (Is getKeys the
    correct way?). All the Hotkey tools do it!?

    Regards,
    Dominik
  • Solved it using GetKeys from carbon.

    #define                keyArrowLeft            0x7b
    #define                keyArrowRight            0x7c
    #define IsKeyDown(keyMap, theKey) (((unsigned char *)(keyMap))
    [(theKey) / 8] & 1 << ((theKey) % 8))
    BOOL isTranslatedKeyDown(KeyMap map, unichar key); //for space and
    similar characters from GT category

    //thanks to Pierre-Olivier Latour and Jonathan Grynspan

    Regards,
    Dominik

    On 14.09.2007, at 14:06, Dominik Pich wrote:

    > Hi,
    > I need to check if a specific key is pressed while receiving a drag.
    > When drags come from inside the process a keydown event is
    > generated as currentEvent and I can get that but for drags from
    > other applications I dont get such an event. I tried getKeys from
    > the carbon layer. I tried the following category on http://
    > www.ghosttiger.com/?p=136 and I can detect presses of CHARACTERS
    > just fine. A b C d <<SPACE>> as the keycodes get translated to
    > unichars for me.
    >
    > What I cant do is detecting arrow keys.
    > The cateogry returns wrong unichar values for it.... Well all arrow
    > keys translate to the same unichar for me...
    > And I dont know how to interpret what getKeys tells me...... sure I
    > can just take the raw codes from the KeyMap but those seem to be
    > different for different keyboards. (not to mention architectures!?)
    >
    > So... how does one go about detecting these keys (Is getKeys the
    > correct way?). All the Hotkey tools do it!?
    >
    > Regards,
    > Dominik
previous month september 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today