Christiaan Kruger
Christiaan Kruger

Reputation: 45

How to prevent a key from being held down on a button? C#

I am writing a game where you need to click a button as many times as you can in 10 seconds. The problem is that it is possible to hold the Enter key down to superspeed the counter.

How can I prevent this? I tried KeyDown Events but it doesn't seem to fire when the key is held down.

Thanks.

Upvotes: 2

Views: 260

Answers (2)

tenfour
tenfour

Reputation: 36896

try handling KeyPress instead of KeyDown.

Upvotes: 1

Albin Sunnanbo
Albin Sunnanbo

Reputation: 47038

Use the MouseClick event as that only captures clicks by the mouse.

Upvotes: 2

Related Questions