How can I get my program to react in a certain way depending on what key the user presses?
For example, while the program is running, if the user presses F12, then it must show, for example, form2.
How would I go about doing this?
How can I get my program to react in a certain way depending on what key the user presses?
For example, while the program is running, if the user presses F12, then it must show, for example, form2.
How would I go about doing this?
Take a look at the KeyDown, KeyPress, and KeyUp events.
If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein
I've tried that and it works, but how do I get it to check if I've pressed F12 or Enter?
I'm not sure what you're asking. Handle the KeyDown event and check the KeyCode property. I had no problem catching F12.
If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein
I found my problem! I was using keydata instead of keycode. Thanks!