Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
Get what key is pressed without event or pausing the application

I need to get the input from the user without pausing the application or having an event. Is there any way that I can get it without events and pausing? Since I have a timer that does other actions and I don't want to add events becuase that will result in messy code. So is there any way to get the key pressed without pausing the app or event?

Thanks.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You could use the User32 API function GetKeyState which allows you to query if a key is pressed. By doing so, you wouldn't need to handle events (or hooks) separately but could do it directly in your timer method.

    [DllImport("user32")]
    public static extern short GetKeyState(int nVirtKey);

This documentation goes into more detail: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getkeystate

Edit: Here is an example of a method using that:

    public static bool LeftCtrlDown()
    {
        return (User32API.GetKeyState(User32API.VK_LCONTROL) & 0x8000) == 0x8000;
    }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!