Reputation: 1
I am making a simple form with a lot of buttons, and I want each button assigned with a letter(ex: q,w,t,y) and when I press that key on the keyboard, that button is 'pressed', like I've clicked on it, and if I press it three times, it's like I've clicked on it three times - you get the idea. I've tried with this:
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
switch (keyData)
{
case Keys.Q:
Q_Button();
return true;
...
It's working but only the first time you press the key - and then the application is dull, no matter how many times you press it again it's not working. Also it's not working for the multiple presses scheme, cos it's only working once - the first time. I need some ideas here. Thanks in advance.
Upvotes: 0
Views: 3048
Reputation: 60468
Assuming you are doing Windows Forms you should use the buttons PerformClick
method.
Upvotes: 1