In C #, the keycode and keyValue can be used to obtain the value you entered from the keyboard. For example:
Private void textbox3_keyup (Object sender, system. Windows. Forms. keyeventargs E)
{
Textbox1.text = E. keycode. tostring ();
Textbox2.text = E. keyValue. tostring ();
}
In this way, you can enter characters in textbox1 and textbox2 to view the corresponding keyboard code and keyboard value.
You may find out, why do textbox1 display uppercase letters after entering uppercase and lowercase characters? In fact, in. net, keys only have upper-case letters and no lower-case letters, so only lower-case letters can be displayed. To solve this problem, use keypresseventargs. Is to use the keypress event of textbox2. The Code is as follows:
Private void textbox2_keypress (Object sender, system. Windows. Forms. keypresseventargs E)
{
Textbox1.text = E. keychar. tostring ();
}
This will show lower case, but it can only show characters (note that E. keychar is char type), so it can only show A-Z, A-Z.