判斷被觸發的鍵盤按鍵或組合鍵

2012070318:24
        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            //判斷被觸發的鍵盤按鍵或組合鍵
            if (e.Control && e.KeyCode != Keys.ControlKey)
            {
                MessageBox.Show("按鍵 Control + " + e.KeyCode.ToString() + " 被觸發了!", "事件");
            }
            else if (e.Shift && e.KeyCode != Keys.ShiftKey)
            {
                MessageBox.Show("按鍵 Shift + " + e.KeyCode.ToString() + " 被觸發了!", "事件");
            }
            else if (e.Alt && e.KeyCode != Keys.Alt && e.KeyCode != Keys.Menu)
            {
                MessageBox.Show("按鍵 Alt + " + e.KeyCode.ToString() + " 被觸發了!", "事件");
            }
            else if (e.KeyValue != 16 && e.KeyValue != 17 && e.KeyValue != 18)
            {
                MessageBox.Show("按鍵 " + e.KeyCode.ToString() + " 被觸發了!", "事件");
            }
            e.Handled = true;   //將Handled設置為true,表示已經處理過KeyPress事件
        }