using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace DataMigrationClient
{
    public class API
    {
        public const int VK_LCONTROL = 162;
        public const int VK_RCONTROL = 163;

        /// <summary>
        /// 左Shift键
        /// </summary>
        public const int VK_LSHIFT = 160;
        /// <summary>
        /// 右Shift键
        /// </summary>
        public const int VK_RSHIFT = 161;

        [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "GetAsyncKeyState")]
        public static extern short GetAsyncKeyState(int vKey);
    }
}
//获取值
short value= API.GetAsyncKeyState(API.VK_LCONTROL);

c# 键值对照表

虚拟键值表
虚拟键十六进制值十进制值相应键盘或鼠标键
VK_LBUTTON11鼠标左键
VK_RBUTTON22鼠标右键
VK_CANCEL33Ctrl-Break键
VK_MBUTTON44鼠标中键
VK_BACK88Backspace键
VK_TAB99Tab键
VK_CLEAR0C12Clear键
VK_RETURN0D13Enter键
VK_SHIFT1016Shift键
VK_CONTROL1117Ctrl键
VK_MENU1218Alt键
VK_PAUSE1319Pause键
VK_CAPITAL1420Caps Lock键
VK_ESCAPE1B27Esc键
VK_SPACE2032Space键
VK_PRIOR2133Page Up键
VK_NEXT2234Page Down键
VK_END2335End键
VK_HOME2436Home键
VK_LEFT2537←键
VK_UP2638↑键
VK_RIGHT2739→键
VK_DOWN2840↓键
VK_SELECT2941Select键
VK_PRINT2A42Print键
VK_EXECUTE2B43Execute键
VK_SNAPSHOT2C44Print Screen键
VK_INSERT2D45Ins键
VK_DELETE2E46Del键
VK_HELP2F47Help键
VK_030480键
VK_131491键
VK_232502键
VK_333513键
VK_434524键
VK_535535键
VK_636546键
VK_737557键
VK_838568键
VK_939579键
VK_A4165A键
VK_B4266B键
VK_C4367C键
VK_D4468D键
VK_E4569E键
VK_F4670F键
VK_G4771G键
VK_H4872H键
VK_I4973I键
VK_J4A74J键
VK_K4B75K键
VK_L4C76L键
VK_M4D77M键
VK_N4E78N键
VK_O4F79O键
VK_P5080P键
VK_Q5181Q键
VK_R5282R键
VK_S5383S键
VK_T5484T键
VK_U5585U键
VK_V5686V键
VK_W5787W键
VK_X5888X键
VK_Y5989Y键
VK_Z5A90Z键
VK_LWIN5B91左Windows键
VK_RWIN5C92右Windows键
VK_APPS5D93应用程序键
VK_SLEEP5F95休眠键
VK_NUMPAD06096小数字键盘0键
VK_NUMPAD16197小数字键盘1键
VK_NUMPAD26298小数字键盘2键
VK_NUMPAD36399小数字键盘3键
VK_NUMPAD464100小数字键盘4键
VK_NUMPAD565101小数字键盘5键
VK_NUMPAD666102小数字键盘6键
VK_NUMPAD767103小数字键盘7键
VK_NUMPAD868104小数字键盘8键
VK_NUMPAD969105小数字键盘9键
VK_MULTIPLY6A106乘号键
VK_ADD6B107加号键
VK_SEPARATOR6C108分割键
VK_SUBSTRACT6D109减号键
VK_DECIMAL6E110小数点键
VK_DIVIDE6F111除号键
VK_F17012F1键
VK_F271113F2键
VK_F372114F3键
VK_F473115F4键
VK_F574116F5键
VK_F675117F6键
VK_F776118F7键
VK_F877119F8键
VK_F978120F9键
VK_F1079121F10键
VK_F117A122F11键
VK_F127B123F12键
VK_F137C124F13键
VK_F147D125F14键
VK_F157E126F15键
VK_F167F127F16键
VK_F1780128F17键
VK_F1881129F18键
VK_F1982130F19键
VK_F2083131F20键
VK_F2184132F21键
VK_F2285133F22键
VK_F2386134F23键
VK_F2487135F24键
VK_NUMLOCK90144Num Lock键
VK_SCROLL9145Scroll Lock键
VK_LSHIFTA0160左Shift键
VK_RSHIFTA1161右Shift键
VK_LCONTROLA2162左Ctrl键
VK_RCONTROLA3163右Ctrl键
VK_LMENUA4164左Alt键
VK_RMENUA5165右Alt键
Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐