开发者

Detecting when the shift key is held down

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 key开发者_JAVA百科Up, which would have been ideal. What am I missing?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜