キーパッドでW/A/S/Dをクリックすると、クリックされた2つのキーの間の時間は測定されません。ここに私の完全なコードは次のとおりです。クリックしたキー間の測定時間
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
stopwatch1.Start();
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = true;
if (e.KeyChar == (char)Keys.W)
{
textBox1.Text = textBox1.Text + "W (" + stopwatch1.ElapsedMilliseconds + ") + ";
}
else if (e.KeyChar == (char)Keys.A)
{
textBox1.Text = textBox1.Text + "A (" + stopwatch1.ElapsedMilliseconds + ") + ";
}
else if (e.KeyChar == (char)Keys.S)
{
textBox1.Text = textBox1.Text + "S (" + stopwatch1.ElapsedMilliseconds + ") + ";
}
else if (e.KeyChar == (char)Keys.D)
{
textBox1.Text = textBox1.Text + "D (" + stopwatch1.ElapsedMilliseconds + ") + ";
}
}
private void textBox1_KeyUp(object sender, KeyEventArgs e)
{
stopwatch1.Stop();
}
}
}
出力例:
W (560) + A (634) + S (753) + D (846) + A (944) +
そして、何私はしたいが、たとえば次のとおりです。
W (560) + A (128) + S (82)
すると、誰かが助けることはできますか?
私はあなたが衝突した2つの出来事があることを意味しています... –