Members - Reputation: 755
Posted 31 March 2012 - 04:44 PM
p.s. If you need more information don't be afraid to ask
Crossbones+ - Reputation: 10505
Posted 31 March 2012 - 11:08 PM
Think of a word processor. If you hold down a letter, it starts repeating after a certain delay, and then repeats at a different rate until you let go. If you press a second key while holding the first, it stops repeating the first letter. Most desktop operating systems assume that the majority of apps will use the keyboard for text entry, so this is the default behavior. This sounds like the problem you're experiencing.
Here's a basic solution for games:
- Make a HashSet<Keys> // assuming Winforms. Change to whatever enum you're using if necessary.
- When you get a keydown event, add that key to the hashset.
- When you get a keyup event, remove that key from the hashset.
- Use a game loop to constantly check the hashset.Contains(Keys.Whatever) and perform your processing there. For basic Winforms apps, the "game loop" can be something simple like a Timer firing at a certain rate.