0

I have one status bar. This status bar has capslock, scroll, numlock, insert/overwrite. Basically, if the user use capslock, the capslock status will be enabled, same case in the scroll, numlock. Insert will be enabled when user insert text within text and the insert status will be changed to overwrite if the user choose to overwrite. Once all of these are not being use, it'll be disabled. User will type text inside a richbox. Please help. So far I've only tried on capslock with this code but it's not working. Please help,I don't have any idea on this.

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.CapsLock)
    {
        caps.Enabled = true;
    }
    else if (e.KeyCode == Keys.NumLock)
    {
        num.Enabled = true;
    }
}
  • So, whar is the question?? What happens and what does or doesn't work?? – TaW Mar 16 '22 at 15:39
  • 1
    The KeyDown event doesn't tell you what STATE those keys were in before they were pressed. They could have been on or off before your app was run and then they simply change state when they are pressed... – Idle_Mind Mar 16 '22 at 18:12
  • `IsKeyLocked(Keys.CapsLock)`, `IsKeyLocked(Keys.NumLock)` etc. -- Update the state as soon as the Form is shown. You then usually handle `Application.Idle` to update these states after. – Jimi Mar 20 '22 at 13:02

0 Answers0