[C#] 鍵盤 KeyChar 值的取得

  • 22394
  • 0
  • 2009-11-05

摘要:C# 鍵盤 KeyChar 值的取得

 

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            char Key_Char = e.KeyChar;//判斷按鍵的 Keychar
            MessageBox.Show(((int)(Key_Char)).ToString());//轉成整數顯示
        }

 

Result:

Key Char
1 2 3 4 5 6 7 8 9 0 Enter a
49 50 51 52 53 54 55 56 57 58 13 97