C# 判斷 上/下/左/右/ESC/Enter 鍵盤輸入
C# 判斷 上/下/左/右/ESC/Enter 鍵盤輸入
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
String direction;
if (e.KeyCode == Keys.Down)
direction = “down”;
if (e.KeyCode==Keys.Left)
direction = “left”;
if (e.KeyCode==Keys.Right)
direction = “right”;
if (e.KeyCode==Keys.Up)
direction = “up”;
if (Keys.Escape)
direction = “ESC”;
if (e.KeyCode == Keys.Enter)
direction = “Enter”;
}