2

How can I detect LWin and RWin keys with hot key?

Right now I'm using the example code given here but it only detect the win key if its used as a modifier. I want to know how to detect the win key. Something like this:

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

But with the ability of detecting it if the form is not focused.

Rotary Heart
  • 1,899
  • 3
  • 29
  • 44
  • 1
    Maybe a duplicate to http://stackoverflow.com/questions/10391025/c-sharp-keyboard-hook – BitTickler Jan 30 '15 at 04:05
  • You need an Hook if you want the ability of decteing it evenf if the form is not focused. I developped one, this link helped me a lot : http://blogs.msdn.com/b/toub/archive/2006/05/03/589423.aspx – TheMightyX2Y Jan 30 '15 at 09:03

1 Answers1

1

I found my answer in this question: C# : Keyboard Hook

Processing Global Mouse and Keyboard Hooks in C#.

I found that article quite useful.

Note: that credits goes to Kendall Frey for answering that SO question.

Community
  • 1
  • 1
Rotary Heart
  • 1,899
  • 3
  • 29
  • 44