Still a programming noob but I'm getting better.

Right now I am programming a simon says game. There are four buttons. My code works perfect in terms of functionality. However, instead of clicking on the button I want to bind keystrokes to it. I've seen many confusing methods and some rather simple. However, I have yet to find a keybinding solution for visual studio 2008. So basically, when the program is running, if I press the 'A' button, then I want my program to act like the red button was just clicked. Thank you!

You want to listen to a keystroke event on your form. To do this, select your form in the visual studio designer and go to the properties panel. Click the lightning bolt (events) icon and double clikc on the KeyDown event.

Event Properties

This will generate the following code

<!-- language: lang-c# -->
private void Form1_KeyDown(object sender, KeyEventArgs e)
{

}

This will fire whenever a key is pressed down. Next, you want to check which key was clicked and handle appropriately

Inside of your the KeyDown method, add the following code:

<!-- language: lang-c# -->
if (e.KeyCode == Keys.A)
{
    //Do stuff when 'A' Key is pressed
}

Also, consider adding a switch statement if you're trying to listen to multiple keys and determine the action based on that, for example:

<!-- language: lang-c# -->
switch (e.KeyCode ) {
    case Keys.A:
        //Preform Code for A
        break;
    case Keys.W:
        //Preform Code for W
        break;
    //You can add as many case statments as you like...
}

You'll have to make sure that KeyPreview is set to true so that keyboard events properly register with the form. This can be done during initialization or on the form properties panel.

Set KeyPreview to True

To call the same code is pretty straight forward. You can either have the red button Click event call into the same method as the keystroke event. If you really wanted, you could leave the logic in the button click event and just call that method and pass nulls as arguments

For example, you could do the following:

<!-- language: lang-c# -->
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.A)
    {
        RedButton_Click(null, null);
    }
}

private void RedButton_Click(object sender, EventArgs e)
{
    //Do red button stuffs
}