In this post, we will discuss how to set Enter and Esc keys in C#.Net windows application. You can also check out my previous posts on:
Suppose I have a Windows Form and two buttons name as btnEnter and btnEsc. I want when the user clicks on entering, btnEnter should respond and similarly when the user clicks on Esc, btnEsc should respond.
Set Enter Key:
For this Open windows form properties, from the properties window, select btnEnter in the AcceptButton properties as shown in the fig below:
Set Esc Key:
For this Open windows form properties, from the properties window, select btnEsc in the CancelButton properties as shown in the fig below:
After that when you open the form, click on Enter key, btnEnter will fire and if you click on Esc, btnEsc code will fire.