Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Keyboard State - is ANY key pressed?

Keyboard State - is ANY key pressed?

Scheduled Pinned Locked Moved C / C++ / MFC
cssdata-structuresquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    goop00
    wrote on last edited by
    #1

    Is there a WIN32 function that will tell me whether any modifier key is pressed? The context is a mouse hook function that is only interested if one or more modifier keys (shift, ctrl, alt) is pressed. If no key is pressed it just passes the event to the next hook. I know that GetKeyState() returns the state of a specified virtual key, and that GetKeyboardState() returns an array of states. But a function that just tells me if ANY modifier key is pressed would add less latency in cases (most of the time) when a key is not pressed. Thanks for listening :-)

    D 1 Reply Last reply
    0
    • G goop00

      Is there a WIN32 function that will tell me whether any modifier key is pressed? The context is a mouse hook function that is only interested if one or more modifier keys (shift, ctrl, alt) is pressed. If no key is pressed it just passes the event to the next hook. I know that GetKeyState() returns the state of a specified virtual key, and that GetKeyboardState() returns an array of states. But a function that just tells me if ANY modifier key is pressed would add less latency in cases (most of the time) when a key is not pressed. Thanks for listening :-)

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      What's wrong with GetAsyncKeyState()?

      "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

      "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

      G 1 Reply Last reply
      0
      • D David Crow

        What's wrong with GetAsyncKeyState()?

        "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

        "The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch

        G Offline
        G Offline
        goop00
        wrote on last edited by
        #3

        Thanks for the reply. Like GetKeyState(), I think GetAsyncKeyState() just tells me about a single key. I would prefer a single function call that tells me whether any modifier has been pressed, thus saving several system calls in the hook context.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups