Keyboard event issue

Posted by Petar Minchev on Stack Overflow See other posts from Stack Overflow or by Petar Minchev
Published on 2010-06-10T06:56:36Z Indexed on 2010/06/10 7:03 UTC
Read the original article Hit count: 288

Filed under:
|

Hello guys!

I have to capture the following keyboard event in a TextBox - SHIFT + 8(on the numpad). This also means the NumLock will be on. When I try the following, nothing is printed:

private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.Shift && e.KeyCode == Keys.NumPad8)
        Console.WriteLine("SHIFT + UP");
}

But CTRL + 8(on the numpad) is working.

private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
    if (e.Control && e.KeyCode == Keys.NumPad8)
        Console.WriteLine("CTRL + UP");
}

Could someone explain me, why SHIFT + 8 isn't fired, but CTRL + 8 is working?

P.S. I wrote + UP, because the user wants to navigate with the numpad arrows and the SHIFT key, but his NumLock will also be on. That's why I catch Keys.NumPad8.

All the best, Petar

© Stack Overflow or respective owner

Related posts about c#

Related posts about keyboard