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 6877381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:35:37+00:00 2026-05-27T04:35:37+00:00

The two key-state functions in the WIndows API, GetKeyState() and GetAsyncKeyState() , both determine

  • 0

The two key-state functions in the WIndows API, GetKeyState() and GetAsyncKeyState(), both determine key state based on key up/down messages rather than the physical state of the key.

I am working on a program which manipulates input, using SendInput(), to release modifier keys (alt, ctrl, etc…), send input, and then re-press the modifier keys.

The problem is that I don’t know if the modifier keys are still pressed after the input is sent because I have sent the key-up event and both of the above mentioned functions return that the key is up regardless of the state of the physical key. So if I assume they are still down, the user is left with a dangling ctrl-down causing problems until the user presses and releases cntl again (or any modifier key). Otherwise the key may be left up even when the physical key is still down.

So is there any way (preferably without anything too low level) to detect the physical key state. Windows-only methods are fine. Key monitoring (listening for key up events) really isn’t possible (or at least really, really not preferable).

  • 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-05-27T04:35:38+00:00Added an answer on May 27, 2026 at 4:35 am

    After much testing, I seem to have figured it out. MSDN states about GetKeyState() :

    The key status returned from this function changes as a thread reads key messages from its message queue.

    GetAsyncKeyState() still works on key up/down messages (not physical key state) however, it just doesn’t wait for the message to be read. So if a key event message is sent via SendInput(), it will still return incorrectly – in fact, it will be incorrect before GetKeyState() because it will be incorrect immediately after the call.

    A simple test to demonstrate this functionality is here (VS2010 solution) or just the source here.

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

Sidebar

Related Questions

i have two tables both are related with primary-foreign key ralation and i have
The two key event argument classes KeyEventArgs and PreviewKeyDownEventArgs each have two properties, KeyCode
If I have a table with two foreign key fields to another table, I.E.
I have a two-column primary key on a table. I have attempted to alter
in MySQL, If I create a unique key on two columns, say UNIQUE KEY
Two tables: COURSE_ROSTER - contains COURSE_ID as foreign key to COURSES USER_ID as field
If you had two snippets: (global-set-key \C-d delete-char) and (define-key global-map \C-d delete-char) Is
I have two tables one has a three column composite key. The other needs
Say I have two classes and have a requirement that the primary key property
I have two variables, key and value , and I want to add them

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.