我的按键有问题。只需按下即可一切正常,但按键又如何呢?代码如下所示:
private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Up || e.Key == Key.Down)
{
moveBall(3);
}
}
感谢回复。
最佳答案
WPF KeyEventArgs 类 has an IsRepeat property如果按住键,则为真。
文章中的示例:
// e is an instance of KeyEventArgs.
// btnIsRepeat is a Button.
if (e.IsRepeat)
{
btnIsRepeat.Background = Brushes.AliceBlue;
}
关于C# WPF 键持有,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20818575/