It looks like you want to query the status of all the keys on the keyboard. The best function for this is to call the Win32 APIGetKeyboardState
, . PInvoke
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool GetKeyboardState(byte [] lpKeyState);
var array = new byte[256];
GetKeyboardState(array);
byte[] / . , . a Key key code byte Key.
public static byte GetVirtualKeyCode(Key key) {
int value = (int)key;
return (byte)(value & 0xFF);
}
Key, -. Keys.Alt, Keys.Control Keys.Shift , , . , Keys.ControlKey, Keys.LShiftKey .. ( , )
, , ,
var code = GetVirtualKeyCode(Key.A);
if ((array[code] & 0x80) != 0) {
} else {
}