Answer the question
In order to leave comments, you need to log in
Why does nothing happen when I press the keyboard?
Hi all.
I wrote a simple code, the essence of which is that by pressing the spacebar on the keyboard, a MessageBox appears and writes that the button is pressed. But for some reason, nothing happens at all when I press the spacebar, there is not even an error. I do not understand what the problem is. Help the fool please.
the code:
using System;
using System.Windows.Forms;
class MyButtonClass : Form
{
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Space)
{
MessageBox.Show("кнопка нажата");
}
}
static void Main()
{
Application.Run(new MyButtonClass());
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question