检测用热键按下的 windows 键

Detect windows key pressed with hotekey

如何使用热键检测 LWinRWin 键?

现在我正在使用给定 here 的示例代码,但它仅在将其用作修饰符时检测获胜键。我想知道如何检测win键。像这样:

private void textBox1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.LWin || e.KeyCode == Keys.RWin) WriteLine("Windows key pressed"); }

但如果表单未聚焦,则可以检测到它。

我在这个问题中找到了答案:C# : Keyboard Hook

Processing Global Mouse and Keyboard Hooks in C#.

I found that article quite useful.

注意:感谢 Kendall Frey 回答了这个 SO 问题。