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. Detecting Key Combination

Detecting Key Combination

Scheduled Pinned Locked Moved C / C++ / MFC
question
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.
  • S Offline
    S Offline
    soup
    wrote on last edited by
    #1

    Hi, I am sure this is an easy one, but I cannot get this information intercepted. I have an Edit View and want to know when the user presses space whilst the left ctrl key is held down. Is this possible? Thanks in advance, Simon

    M 1 Reply Last reply
    0
    • S soup

      Hi, I am sure this is an easy one, but I cannot get this information intercepted. I have an Edit View and want to know when the user presses space whilst the left ctrl key is held down. Is this possible? Thanks in advance, Simon

      M Offline
      M Offline
      Matt Gullett
      wrote on last edited by
      #2

      3 ways I can think of do do this: 1) Create an accelerator and handle it in your view class. 2) Overide the WM_KEYDOWN message and check for the space key and call GetAsyncKeyState (or is it GetKeyState) to see if the control key is down. 3) Overide the PreTranslateMessage function, check for WM_KEYDOWN and do step 2.

      S 1 Reply Last reply
      0
      • M Matt Gullett

        3 ways I can think of do do this: 1) Create an accelerator and handle it in your view class. 2) Overide the WM_KEYDOWN message and check for the space key and call GetAsyncKeyState (or is it GetKeyState) to see if the control key is down. 3) Overide the PreTranslateMessage function, check for WM_KEYDOWN and do step 2.

        S Offline
        S Offline
        soup
        wrote on last edited by
        #3

        Hi Matt, Thanks for the response, you put me in the right place! I handle WM_KEYDOWN already, so I elected for option 2, and you are right to mention GetKeyState. It works when I do the following: if((nChar == 32) && (GetKeyState(VK_CONTROL) >> 7) == -1)) { // it happened } Is this how you would expect to do it? Simon

        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