Now you can capture any key pressed on the keyboard, not only restricted to the English or your language letters but also various other keys such as the Windows Key, Properties Key, F1, F2 and other function buttons, the Home, PageUp and PageDown etc.
When you check the value of e.KeyCode.ToString() for various other keys such as the WinKey you will get a value of "LWin" for the String returned. The value of the KeyCode() is exactly the same for the capital and small letters of the languages but the value for the special buttons varies as shown below:
- "LWin" for WinKey (Windows Key)
- "ControlKey" for Control Key
- "ShiftKey" for Shift Key
- "Menu" for the Alt Key (Alternate)
- "Apps" for the Property Key (usually beside the Right Ctrl Key)
- "Oemtilde" for the tilde Key (Left of the Numerical 1)
- "Escape" for Escape Key
- "Next" for Page Down
- "Up" for Up, "Down" for Down etc.
- "Return" for Enter Key
- "A" for A; "B" for B "C" for C etc.
- "a" for a; "b" for b; "c" for c etc.
Watch Code Below followed by the Source Code:
public partial class Form1 : Form
this.KeyDown += Form1_KeyDown;
void Form1_KeyDown(object sender, KeyEventArgs e)
lblKeyPressed.Text = e.KeyCode.ToString();
if (e.KeyCode.ToString() == "ControlKey")
checkCtrl.Checked = !checkCtrl.Checked;
if (e.KeyCode.ToString() == "ShiftKey")
checkShift.Checked = !checkShift.Checked;
if (e.KeyCode.ToString() == "Menu")
checkAlt.Checked = !checkAlt.Checked;
private void Form1_Load(object sender, EventArgs e)
MessageBox.Show("Created by www.Code-Kings.com");
Directly Download Source Code for Visual Studio 2012 Here