Virtual-Key Codes 
The following table shows the symbolic constant names, hexadecimal values, and mouse or keyboard equivalents for the virtual-key codes used by the system. The codes are listed in numeric order. ConstantsVK_LBUTTON  (0x01) 
Left mouse button VK_RBUTTON  (0x02) 
Right mouse button VK_CANCEL  (0x03) 
Control-break processing VK_MBUTTON  (0x04) 
Middle mouse button (three-button mouse) VK_XBUTTON1  (0x05) 
Windows 2000/XP: X1 mouse button VK_XBUTTON2  (0x06) 
Windows 2000/XP: X2 mouse button -  (0x07) 
Undefined VK_BACK  (0x08) 
BACKSPACE key VK_TAB  (0x09) 
TAB key -  (0x0A-0B) 
Reserved VK_CLEAR  (0x0C) 
CLEAR key VK_RETURN  (0x0D) 
ENTER key ..................上面是MSDN上的部门虚键码
请问这些码值有没有集成于C#类中,请问是哪个类或命名空间?
或是哪一位朋友有这个虚键码的常数或枚举类,可以传给我,不胜感激!

解决方案 »

  1.   

    可以用GetKeyState API来实现
    [DllImport("user32.dll")]
    static extern short GetKeyState(VirtualKeyStates nVirtKey);
    private enum VirtualKeyStates : int
    {
        VK_LBUTTON       = 0x01,
        VK_RBUTTON       = 0x02,
        VK_CANCEL    = 0x03,
    ....
    if(GetKeyState(VirtualKeyStates.VK_CAPITAL ))&0x01!=0)
          MessageBox.Show("Capslock锁定");
    http://msdn.microsoft.com/zh-cn/library/ms645540
      

  2.   


    自己写了个类,地址如下:http://www.it-xm.com/thread-121-1-1.html
    有需要兄弟可以去下
      

  3.   

    System.Windows.Forms.Keys枚举。Kyes.Cancel      // 0x3
    Keys.MButton     //
    Keys.Enter       // 0xd
    Keys.Return      // 0xd
    ...