Get the status of the keyboard and check the status of the keys you want.
Events are not the best way to play games. You need a faster answer.
[DllImport("user32.dll")]
public static extern int GetKeyboardState(byte [] lpKeyState);
...
byte[] bCharData = new byte[256];
GetKeyboardState(bCharData);
, ,
[DllImport("user32.dll")]
static extern short GetKeyState(VirtualKeyStates nVirtKey);
...
public static bool IsKeyPressed(VirtualKeyStates testKey)
{
bool keyPressed = false;
short result= GetKeyState(testKey);
switch (result)
{
case 0:
keyPressed = false;
break;
case 1:
keyPressed = false;
break;
default:
keyPressed = true;
break;
}
return keyPressed;
}
.
, . , . :)