GetAsyncKeyState Function--------------------------------------------------------------------------------The GetAsyncKeyState function determines whether a key is up or down at the time the function is called, and whether the key was pressed after a previous call to GetAsyncKeyState. SyntaxSHORT GetAsyncKeyState(          int vKey
);
ParametersvKey
[in] Specifies one of 256 possible virtual-key codes. For more information, see Virtual-Key Codes. 
Windows NT/2000/XP: You can use left- and right-distinguishing constants to specify certain keys. See the Res section for further information.Return ValueIf 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. 

解决方案 »

  1.   

    如果函数成功调用, 返回值指示自从最后一次调用GetAsyncKeyState以来, 该键是否已被按下, 并且这个键在当前是弹起还是按下.如果最高位被设置,键是被按下的,如果最低位被设置, 该键在上一次调用GetAsyncKeyState后, 它应该是被按下的.无论怎样,你不应该依赖于这个最终行为,获取更多信息见Res段.
      

  2.   

    就是说如果返回值是负的(对于short型就是最高位为1),则键处于被按下状态。
      

  3.   

    "最"高位置1
    就是这样的 1xxx,xxxx,xxxx,xxxx
    对于short型的数据来说,最高位置1,代表它是负的,所以你可以用返回值是否小于零来判断键是否被按下。