Want to trap CTRL+K - Programmer

This is a discussion on Want to trap CTRL+K - Programmer ; Hi I am writing an application using MFC, and I want my application to perform some operations when user presses CONTROL key and 'k' together.I have tried using onKeyDown but I can find out if user has pressed 'Control' key.I ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Want to trap CTRL+K

  1. Want to trap CTRL+K

    Hi

    I am writing an application using MFC, and I want my application to
    perform some operations when user presses CONTROL key and 'k'
    together.I have tried using onKeyDown but I can find out if user has
    pressed 'Control' key.I am not able to figure out how can I find out
    if user has pressed both the keys together.

    Thanks,
    Muskaan

  2. Re: Want to trap CTRL+K

    On 1 Mar 2004 13:57:04 -0800, gshru@yahoo.com (Muskaan) wrote:

    >Hi
    >
    >I am writing an application using MFC, and I want my application to
    >perform some operations when user presses CONTROL key and 'k'
    >together.I have tried using onKeyDown but I can find out if user has
    >pressed 'Control' key.I am not able to figure out how can I find out
    >if user has pressed both the keys together.


    Use the OnChar function for printable characters rather than Keydown.

    Include the line:

    int Ctrl = GetKeyState( VK_CONTROL ) & 0x8000 ;

    in your OnChar function.

    The status you get will be the state of the control key *at the time the message
    (keydown) was generated*, so it will tell you if the control key was down when
    the K key was pressed.

    Alternately, set and clear a flag for Control by looking for the control key
    being pressed in OnKeyDown, and released in OnKeyUp


    Quandon


+ Reply to Thread