如何判断同时按下两个方向键?
是这样的,我现在在WinForm上画了个点
比如我要同时按下下方向键和有方向键,那么这个点就会移动到其对角线的位置
请问如何实现,谢谢:)
------解决方案--------------------[DllImport( "user32.dll ")]
public static extern short GetKeyState(int nVirtKey);
public const int VK_LEFT = 37;
public const int VK_UP = 38;
public const int VK_RIGHT = 39;
public const int VK_DOWN = 40;
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
switch (e.KeyCode)
{
case Keys.Left:
case Keys.Right:
case Keys.Down:
case Keys.Up:
if (((GetKeyState(VK_RIGHT) & 0x80) == 0x80) &&
((GetKeyState(VK_DOWN) & 0x80) == 0x80))
MessageBox.Show( "Zswang 路过 ");
break;
}
}