Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8318289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:54:51+00:00 2026-06-08T21:54:51+00:00

I have a simple WPF application and I need to capture F1 key pressed

  • 0

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:

AddHandler(Keyboard.KeyDownEvent, (KeyEventHandler)KeyPressed);
private void KeyPressed(object sender, KeyEventArgs e)
{
      if (e.Key == Key.F1)
      {
           //my code went here
      }
}

But this doesn’t work when my window isn’t activated.

So, my question is: how to detect global key press?

I repeat: It is a WPF application.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:54:54+00:00Added an answer on June 8, 2026 at 9:54 pm

    No need to Keyboard Hooking. Just use RegisterHotKey (Defines a system-wide hot key) and UnregisterHotKey from Windows API. Try using these in C# from pinvoke.net or these tutorials:

    • Global Hotkeys: Register a hotkey that is triggered even when form isn’t focused.
    • Simple steps to enable Hotkey and ShortcutInput user control

    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 VK_F1 (0x70).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple text box in a WPF application. I need to know
I have a simple WPF application with a menu. I need to add menu
I have a simple WPF application that uses ClickOnce to handle installing. Within this
I have a simple WPF application where I don't have any mvvm framework like
I have this simple code in a WPF application: ThreadStart start = delegate() {
I need the DocumentViewer WPF control (for XPS files) in a Windows Form application.
It is about WPF application which generates reports. Reports have simple structure: byte[] m_Data,
So I have a simple C#/WPF 4.0 application that includes several SurfaceTextBox instances. When
I have a simple WPF window that has 12 buttons on it. I want
I have a simple WPF application I'm working on, which performs a SQL query

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.