spunit
spunit

Reputation: 565

Recognizing the Menu Key in KeyDown

I want to do something when the user pushes this button, when inside a textbox. This is what I tried:

private void txtInvisible_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Menu)
    {
        MessageBox.Show("the context menu key was pressed");
    }
}

I tried Keys.L for example, and that triggered it. So maybe the Keys.Menu is the wrong key?

Upvotes: 1

Views: 1038

Answers (3)

blfuentes
blfuentes

Reputation: 2827

Just use the Keys.Apps key.

private void txtInvisible_KeyDown(object sender, KeyEventArgs e)
{
    if(e.KeyCode == Keys.Apps)
    {
        MessageBox.Show("the context menu key was pressed");
    }  
}

Upvotes: 2

Koen
Koen

Reputation: 644

Like stated before. keys.Apps is what you are looking for. Here you can find all the keys

Upvotes: 2

user927976
user927976

Reputation:

It should be Keys.Apps.

See these other questions:
How can i handle the key that was left to the Right control key
What does WPF call the "Menu" key?

Upvotes: 4

Related Questions