tags:

views:

105

answers:

1

I am trying to detect when the shift key (either side) is held down by the user (without pressing any other keys), but I can't figure out to do this. This is the only thing I found to detect pressing a shift key:

   protected boolean keyStatus(int keycode, int time)
   {
    System.out.println("down");
    boolean retVal = false;
    int key = Keypad.key(keycode);
    if( key == Keypad.KEY_SHIFT_LEFT )
    {
            // do something
        retVal = true;
    }
    else if( key == Keypad.KEY_SHIFT_RIGHT )
    {
            // do something
        retVal = true;
    }
    return retVal;
   }

Shift doesn't trigger keyDown and keyUp, which would have been ideal. What am I missing?

A: 

Does holding down the shift key trigger multiple keypresses? If so, you could write a function to detect a certain number of keypresses within a given amount of time.

Jim Greenleaf
The shift key doesn't trigger keyDown, keyChar, keyControl or keyRepeat as far as I can tell. Keeping it pressed doesn't re-trigger keyStatus either.
ADB