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?
Printable View
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.
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.
I found my problem! I was using keydata instead of keycode. Thanks!