use GetAsyncKeyState to obtain the *current* state of the keyboard

解决方案 »

  1.   

    GetAsyncKeyState( VK_CONTROL )的返回值为多少时,才能确定是按下了ctrl键?
      

  2.   

    TO: yarshray(saga jion)
    什么逻辑值?
    如果ctrl被按下,GetAsyncKeyState( VK_CONTROL )的返回值是-32786.
      

  3.   

    if ((GetAsyncKeyState( VK_CONTROL ) & 0x8000) != 0)
    {
    //down
    }see
    http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/getasynckeystate.asp?frame=true
    If the function succeeds, the return value specifies whether the key was pressed since the last call to GetAsyncKeyState, and whether the key is currently up or down. If the most significant bit is set, the key is down, and if the least significant bit is set, the key was pressed after the previous call to GetAsyncKeyState. However, you should not rely on this last behavior; for more information, see the Res. 
      

  4.   

    TO: saucer(思归) 
    非常感谢!
    0x8000是个什么意思?
      

  5.   

    the most significant bit , :-)1000000000000000
      

  6.   

    谢谢,我知道什么意思了:)
    表示 Int16 的最小可能值。此字段为常数,常数的值为 -32768;即十六进制的 0x8000