窗体无法接受键盘消息

用窗体生成器自动生成的代码

  private void Form1_KeyDown(object sender, KeyEventArgs e) {
            MessageBox.Show("af");
            if (listBox1.Items.Contains(e.KeyCode)) {
                listBox1.Items.Remove(e.KeyCode);
                listBox1.Refresh();


                //this part will increse the difficult of the game by putting down the interval
                if (timer1.Interval > 400) timer1.Interval -= 10;
                if (timer1.Interval > 250) timer1.Interval -= 8;
                if (timer1.Interval > 100) timer1.Interval -= 2;


                status.Update(true);
            } else {
                status.Update(false);
            }
            progressBar1.Value = 800 - timer1.Interval;
            labelCorrect.Text = "correct:  "+status.correct.ToString();
            LabelMiss.Text = "missed:  "+100;
            labelTotal.Text = "total;  "+status.total.ToString();
            labelAccuracy.Text = "Accuracy: "+status.total.ToString();

        }

按键之后程序无响应 对话框也弹不出来 求大神讲解

Form的keypreview设置为true
看下Form1_KeyDown有没有绑定到KeyDown事件上

看下窗体属性里面,事件有没有添加Form1_KeyDown添加监听。

对话框也弹不出来 说明Form1_KeyDown事件都没有执行,你到designer文件里面搜一下Form1_KeyDown是否被绑定了
或者可能代码里面有捕获系统消息然后吃掉了

用spy++看下你的窗体是否真的有接收到你的消息