2009-06-09 38 views

回答

2

檢查Control.ModifierKeys ...

[STAThread] 
    static void Main(string[] args) 
    { 
     if (Control.ModifierKeys == Keys.ShiftKey) 
     { 
      // Do something special 
     } 
    } 
+0

任何關心解釋他們爲什麼低估了我的答案? – 2009-06-09 11:46:54

13

的ModifierKeys屬性看起來理想:

private void Form1_Load(object sender, EventArgs e) 
{ 
    if ((ModifierKeys & Keys.Shift) != 0) 
    { 
     MessageBox.Show("Shift is pressed"); 
    } 
} 
0

我知道這個帖子是相當老了,但我遇到了這個問題,並通過修改固定它傑米代碼:

[STAThread] 
static void Main(string[] args) 
{ 
    if (Control.ModifierKeys.ToString() == "Shift") 
    { 
     // Do something special 
    } 
} 
相關問題