Multiple C # Key Presses

I program the game in Microsoft Visual Studio C # and I have to catch many keys at the same time. I cannot detect Q, W, E, R, T, Y at the same time, but I can determine Q, W, E, R, T, A.

I tried using KeyDown and [DllImport("user32.dll")] , but both of them have 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"); } 
+4
source share
2 answers

This may be related to your keyboard. When I was a gamer, I know that it is a property of keys to send multiple keystrokes at the same time; Depending on the keyboard, the number will be different, but different combinations will or will not work.

+5
source

This is called key scrolling. USB keyboards only support scrolling of the final key, while some smart PS / 2 keyboards have n-key rollovers (many many keys can be pressed simultaneously without disabling additional keystrokes)

Read: Wikipedia Description

+3
source

Source: https://habr.com/ru/post/1481981/


All Articles