How do i check if the Left Shift key was pressed?
-
I tried using this code : if ((Control.ModifierKeys & Keys.LShiftKey) == Keys.LShiftKey) and a few other combinations but it doesn't work. I can detect just the shift key being pressed but i want to detect if the LEFT shift key (which is more specific) being pressed. Is there any way?
-
I tried using this code : if ((Control.ModifierKeys & Keys.LShiftKey) == Keys.LShiftKey) and a few other combinations but it doesn't work. I can detect just the shift key being pressed but i want to detect if the LEFT shift key (which is more specific) being pressed. Is there any way?
both shift keys ( the one on the left of the keyboard and the one on the right ) hold the same value "16" so no way to tell , but if you wish to catch events such as the up / down arrows etc... you can do something like this : C#:
private void Form1_Load(object sender, System.EventArgs e)
{
this.KeyPreview=true;
}
// set keypreview on.
///////////////////
protected override bool ProcessKeyPreview(ref System.Windows.Forms.Message m)
{
switch (m.WParam.ToInt32())
{
case 38: // up arrow key
MessageBox.Show("you clicked UP!");
break;
case 40: // down arrow key
MessageBox.Show("you clicked DOWN!");
break;
case 37: // left arrow key
MessageBox.Show("you clicked LEFT!");
break;
case 39: // right arror key
MessageBox.Show("you clicked RIGHT!");
break;
}
return true;
}
hope it helps. Vb:
Public Function TwinsOnWay(ByVal twins As String) As String
Select Case twins
Case "Gender"
Return "Two Girls"
End Select
End Function