I am trying to detect if the Numlock is pressed. I can do it okay with
the CapsLock or the ScrLk, but not with NumLock. The code for all three
checks is exactly the same, but for some reason numlock always thinks it
is on.
Z.K.
code:
private void MainForm_KeyDow n(object sender, KeyEventArgs e)
{
if (Control.IsKeyL ocked(Keys.NumL ock))
{
MessageBox.Show ("The Num Lock key is ON.");
}
else
{
MessageBox.Show ("The Num Lock key is OFF.");
}
if (Control.IsKeyL ocked(Keys.Caps Lock))
{
MessageBox.Show ("The Caps Lock key is ON.");
}
else
{
MessageBox.Show ("The Caps Lock key is OFF.");
}
if (Control.IsKeyL ocked(Keys.Scro ll))
{
MessageBox.Show ("The Scroll Lock key is ON.");
}
else
{
MessageBox.Show ("The Scroll Lock key is OFF.");
}
}
the CapsLock or the ScrLk, but not with NumLock. The code for all three
checks is exactly the same, but for some reason numlock always thinks it
is on.
Z.K.
code:
private void MainForm_KeyDow n(object sender, KeyEventArgs e)
{
if (Control.IsKeyL ocked(Keys.NumL ock))
{
MessageBox.Show ("The Num Lock key is ON.");
}
else
{
MessageBox.Show ("The Num Lock key is OFF.");
}
if (Control.IsKeyL ocked(Keys.Caps Lock))
{
MessageBox.Show ("The Caps Lock key is ON.");
}
else
{
MessageBox.Show ("The Caps Lock key is OFF.");
}
if (Control.IsKeyL ocked(Keys.Scro ll))
{
MessageBox.Show ("The Scroll Lock key is ON.");
}
else
{
MessageBox.Show ("The Scroll Lock key is OFF.");
}
}
Comment