what is the ascii code of windows key? in my c# application I want to lock or disable windows key.
Sorry, you can use the KeyCode :
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode != Keys.LWin && e.KeyCode != Keys.RWin)
MessageBox.Show("Hello " + e.KeyData.ToString());
}
I'm fairly sure that they don't have ascii codes, but they do have key codes: VK_LWIN
and VK_RWIN
for the left and right one.
So for example in Control.KeyDown
you'll get a KeyEventArgs that has a KeyCode
property which you can compare with Keys.LWin
or Keys.RWin
.
Actually keys like the Windows key don't have an ASCII value. Only keys that are 'printable' have an ASCII value. To detect keys like the Windows key you have to use either the KeyDown or KeyUp events and use the KeyCode to detect which key was pressed.KeyCode for this key is 93.
Ex:-
Private Sub txt_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = 93 Then msgbox "93" End If End Sub
There isn't an Ascii-Code because the WinKey is not printable. However you can use the virtual key code of these keys as described in the msdn.