我做了一个方法来检测按键何时被按下,但它不起作用!继承我的代码
void KeyDetect(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.W && firstload == true)
{
MessageBox.Show("Good, now move to that box over to your left");
firstload = false;
}
}
Run Code Online (Sandbox Code Playgroud)
我也尝试创建一个keyeventhandler但是,它"无法分配给密钥检测,因为它是一个方法组"
public Gwindow()
{
this.KeyDetect += new KeyEventHandler(KeyDetect);
InitializeComponent();
}
Run Code Online (Sandbox Code Playgroud)