我写了一个检测按键是否按下的方法,但它不起作用!这是我的代码。
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;
}
}
我还尝试了制作一个keyeventhandler,但是它显示“无法分配到key detect,因为它是一个方法组”。
public Gwindow()
{
this.KeyDetect += new KeyEventHandler(KeyDetect);
InitializeComponent();
}
=
吗?此外,我认为你不需要额外的括号。 - anon==
符号是用于检查相等性而不是赋值。 - Ron Zhang