I have a simple WPF application and I need to capture F1 key pressed in Windows (Operation System), even if my WPF window is minimized, or it isn't activated.
I have problems with detecting this. I searched on Internet and I found many results, but they didn't helped me.
For detecting a key pressed inside of application I used this simple code:
private void KeyPressed(object sender, KeyEventArgs e)
if (e.Key == Key.F1)
//my code went here
There is a sample in Microsoft Forums.
You can use these modifiers and Virtual-Key Codes:
MOD_ALT (0x0001) MOD_CONTROL (0x0002) MOD_NOREPEAT (0x4000) MOD_SHIFT (0x0004) MOD_WIN (0x0008)
for example F1 key is