Thread: WM_KEYDOWM message

  1. #1
    Registered User
    Join Date
    Jul 2010

    WM_KEYDOWM message

    I use the WM_KEYDOWN message(by checking wParam for a specific key of course) in my application to start an animation and use the WM_KEYUP message to tell when the key is released and stop the animation.

    But Windows have that autorepeat feature and when the key is preesed continuously many WM_KEYDOWN messages are received before an KEYUP message resulting my animation start again and again.

    How can I get rid of this?

    Thanks for help in advance!

  2. #2
    Join Date
    Oct 2007
    Inside my computer
    You can't. Check for the first message, set a flag, wait for keyup and reset the flag.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Jul 2010
    Thanks for reply. I came up to the following:
    BOOL keys[256]; // Flags for all keys
    The keys array will be initialized to false.
    The WM_KEYUP handler:
    case WM_KEYUP:
        keys[wParam] = FALSE;
    The WM_KEYDOWN handler:
    case WM_KEYDOWN:
        if(keys[wParam] == FALSE)
             keys[wParam] = TRUE;
             // The key is pressed for the first time
            /* ..... .... */
            // Key is already pressed pressed. Skip....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strange string behavior
    By jcafaro10 in forum C Programming
    Replies: 2
    Last Post: 04-07-2009, 07:38 PM
  2. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  3. Making a script language?
    By Blackroot in forum Game Programming
    Replies: 10
    Last Post: 02-16-2006, 02:22 AM
  4. Dialog Box Problems
    By Morgul in forum Windows Programming
    Replies: 21
    Last Post: 05-31-2005, 05:48 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM