Q:

How to detect when arrow key down is pressed / C# WPF

I'm working with WPF C# app, and I need to implement some action when arrow key down on keyboard is pressed, for example:
private void Window_KeyDown(object sender, KeyEventArgs e)
{
    // Here I gotta check is that arrow key down which invoked this event.. then call a method
    DoSomething();
}

I simply can not figure out in wpf how to detect a arrow key down .. 
Any kind of help would be great! 
Thanks !

A:

The KeyEventArgs hold information about the pressed key in the KeyEventArgs.Key property and so you can check for the down arrow key by checking if e.Key is equal to Key.Down, which is the enumeration value for the arrow down key.
private void Window_OnKeyDown(object sender, KeyEventArgs e)
{
    if (e.Key == Key.Down) // The Arrow-Down key
    {
        DoSomething();
    }
}

