I'm using the following code to check is NumLock, CapsLock or Insert are pressed, and if their status is ON update a label's text accordingly. But for some reason I can't get NumLock to work properly. It updates the label's text with "Num" if NumLock is set on but fails to update if NumLock is set off. Every other check in the code works. Would appreciate any help. Thank you.
private void num_ins_caps_keyDown(object sender, KeyEventArgs e)
{
if ((e.KeyCode & Keys.KeyCode) == Keys.CapsLock)
{
if (Control.IsKeyLocked(Keys.CapsLock))
num_ins_caps1.capsLabel.Text = "Caps";
else
num_ins_caps1.capsLabel.Text = null;
}
if ((e.KeyCode & Keys.KeyCode) == Keys.NumLock)
{
if (Control.IsKeyLocked(Keys.NumLock))
num_ins_caps1.numLabel.Text = "Num";
else
num_ins_caps1.numLabel.Text = null;
}
if ((e.KeyCode & Keys.KeyCode) == Keys.Insert)
{
if (Control.IsKeyLocked(Keys.Insert))
num_ins_caps1.insLabel.Text = "Ins";
else
num_ins_caps1.insLabel.Text = null;
}
}