多个同时按键C# [英] multiple simultaneous key press c#
问题描述
我编程在Microsoft Visual Studio C#中的比赛,我必须同时大量赶上钥匙的。我无法检测Q,W,E,R,T,Y在同一时间,但我可以检测Q,W,E,R,T,A。
我试图用KeyDown和函数[DllImport(user32.dll中)]
,但他们都有着相同的结果。什么是Y和A键之间的差异如何解决这个问题呢?
INT代码1 = GetVirtualKeyCode(Keys.Q) ;
INT代码2 = GetVirtualKeyCode(Keys.W);
INT CODE3 = GetVirtualKeyCode(Keys.E);
INT码4 = GetVirtualKeyCode(Keys.R);
INT code5 = GetVirtualKeyCode(Keys.T);
INT code6 = GetVirtualKeyCode(Keys.Y);
如果((数组[代码1]放大器; 0x80的)= 0&安培;!&安培;
(数组[代码2]放大器; 0x80的)= 0&安培;!&安培;
(数组[CODE3 &安培; 0x80的)= 0&安培;!&安培;
(数组[码4]放大器; 0x80的)= 0&安培;!&安培;
(数组[code5&放大器;!0x80的)= 0&安培; &安培;
(数组[code6&安培; 0x80的)= 0)
{
listBox1.Items.Add(asdasdasd)!;
}
这可能与你的键盘。当我是一个游戏玩家,我知道这是能够同时发送多个键盘按键的属性;根据在键盘上,数量将有所不同,但也不同的组合会或不会工作。
I am programming a game in microsoft visual studio c# and I have to catch lot's of keys simultaneously. I can't detect Q,W,E,R,T,Y at the same time but I can detect Q,W,E,R,T,A.
I tried to use KeyDown and [DllImport("user32.dll")]
but both of them has the same result. What is the difference between Y and A keys and how can I solve this problem?
int code1 = GetVirtualKeyCode(Keys.Q);
int code2 = GetVirtualKeyCode(Keys.W);
int code3 = GetVirtualKeyCode(Keys.E);
int code4 = GetVirtualKeyCode(Keys.R);
int code5 = GetVirtualKeyCode(Keys.T);
int code6 = GetVirtualKeyCode(Keys.Y);
if ((array[code1] & 0x80) != 0 &&
(array[code2] & 0x80) != 0 &&
(array[code3] & 0x80) != 0 &&
(array[code4] & 0x80) != 0 &&
(array[code5] & 0x80) != 0 &&
(array[code6] & 0x80) != 0)
{
listBox1.Items.Add("asdasdasd");
}
It may be related to your keyboard. When I was a gamer, I know that it was a property of keyboards to be able to send multiple keystrokes at the same time; Depending on the keyboard, the number would differ, but also the different combinations would or wouldn't work.
这篇关于多个同时按键C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!