I
I
ITLDS2019-07-08 12:20:58
C++ / C#
ITLDS, 2019-07-08 12:20:58

How to handle KeyDown event for arrows?

Faced such problem: KeyDown event is not processed. Here is the handler itself:

public Form1()
{
    InitializeComponent();
    this.KeyPreview = true;
    this.KeyDown += Form1_KeyDown;
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
    MessageBox.Show(e.KeyValue.ToString());
}

The message is not displayed when I click on the arrows. In all other cases it is displayed. What am I doing wrong? Works with KeyUp, but KeyDown is needed for my task.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
eRKa, 2019-07-08
@ITLDS

https://docs.microsoft.com/en-us/dotnet/api/system...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question