I recommend you use the following:
//otros using
using System.Runtime.InteropServices;
namespace Ejemplo
{
public partial class MainWindow : Form
{
[DllImport("User32.dll")]
private static extern short GetAsyncKeyState(Keys teclas);
[DllImport("user32.dll")]
private static extern short GetAsyncKeyState(Int32 teclas);
public MainWindow()
{
InitializeComponent();
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
for (int i = 0; i<=255; i++)
{
int numcontrol = GetAsyncKeyState(i);
if (numcontrol == -32767) // Verificamos si numcontrol fue
realmente presionado controlando que numcontrol sea -32767
{
if (Convert.ToBoolean(GetAsyncKeyState(Keys.Up)))
{
MessageBox.Show("Up");
}
if (Convert.ToBoolean(GetAsyncKeyState(Keys.Down)))
{
MessageBox.Show("Down");
}
if (Convert.ToBoolean(GetAsyncKeyState(Keys.W)))
{
MessageBox.Show("W");
}
if (Convert.ToBoolean(GetAsyncKeyState(Keys.W)))
{
MessageBox.Show("S");
}
}
}
}
}
}
You add a Timer in the Windows control, double click and the event Tick will do, which will listen when something is done about the control, either click or a key and then verify which key was pressed and call to what you want to do.