GetAsyncKeyState() (Key pressing)

This is a discussion on GetAsyncKeyState() (Key pressing) within the Game Programming forums, part of the General Programming Boards category; hey, i was wondering how i can recieve a key with GetAsyncKeyState(VK_Key), or such, so when the person holds down ...

  1. #1
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035

    GetAsyncKeyState() (Key pressing)

    hey, i was wondering how i can recieve a key with GetAsyncKeyState(VK_Key), or such, so when the person holds down the button it only reacts once. for example, i say that a little picture moves a pixel right each time the right arrow key is found. but i don't want the little picture moving right 20 pixels if the user holds down the arrow key.
    thanks!

  2. #2
    The Earth is not flat. Clyde's Avatar
    Join Date
    Mar 2002
    Posts
    1,420
    Code:
    bool key = true;
    
    if (GetAsyncKeyState(VK_Key))
    {
           if (key)
           {
                   code goes here
           }
           key = false;
    }
    
    else
           key = true;

  3. #3
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    OH MY GOD THANK YOU!
    you are my new best friend, clyde

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    hehe nice post count number:

    Clyde
    The Earth is not flat.

    Registered: Mar 2002
    Location:
    Posts: 555
    "There are three kinds of people in the world...
    Those that can count and those that can't."

  5. #5
    The Earth is not flat. Clyde's Avatar
    Join Date
    Mar 2002
    Posts
    1,420
    "OH MY GOD THANK YOU!"

    Your welcome

    "hehe nice post count number:"

    Heh the next one like that will be 666..... ominous eh =)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 11-23-2007, 01:48 PM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  3. Directional Keys - Useing in Console
    By RoD in forum C++ Programming
    Replies: 38
    Last Post: 10-06-2002, 05:42 PM
  4. FAQ: Directional Keys - Useing in Console
    By RoD in forum FAQ Board
    Replies: 38
    Last Post: 10-06-2002, 05:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21