Thread: Keyboard input

  1. #1
    Registered User
    Join Date
    Oct 2006
    Location
    New York
    Posts
    124

    Keyboard input

    would it be efficient to use GetKeyState(), to determine the input the user presses or is there another method. My idea was to get input only in the client, or maybe giving the user an option for custom control...
    Last edited by Darkinyuasha1; 06-18-2007 at 09:26 PM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    What kind of "windows" program are you creating?

    If it's a regular windows program with a GUI window, then use the various WM_* messages to track what the user is doing.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Location
    New York
    Posts
    124
    What i mean is instead of gui, i want controls to move an image (game control basically) i'm trying to handle key events
    Last edited by Darkinyuasha1; 06-18-2007 at 11:16 PM.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    You mean like "OK" and "Cancel" on a dialog?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User Queatrix's Avatar
    Join Date
    Apr 2005
    Posts
    1,342
    You are being very hard to understand Darkinyuasha1. From the best I can tell, your looking for the WM_KEYDOWN notification; use it in your window's callback's message switch.

  6. #6
    Registered User
    Join Date
    Oct 2006
    Location
    New York
    Posts
    124
    well i can use WM_KEYDOWN
    using th wParam

    Code:
    WM_KEYDOWN:
    if(wParam == VK_LEFT)
    //do something
    or could i use GetKeyState()
    to capture an input key and then determine
    what event i would do when the user presses it .

  7. #7
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Code:
    case WM_KEYDOWN:
         switch(wParam){
              case VK_LEFT:
                   // do something here
                   break;
              }
         break;
    GetKeyState() is only if you expect the player to be pressing multiple keys simultaneously and you need to know which keys are pressed. This is useful when you have 'modifier' keys, such as SHIFT+D does something different than pressing the shift key then the D key seperately
    Last edited by abachler; 06-19-2007 at 11:43 AM.

  8. #8
    Registered User
    Join Date
    Oct 2006
    Location
    New York
    Posts
    124
    ooooh thanks for clarifying i understand now..

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help using inline assembly for keyboard input
    By sleventeen in forum C Programming
    Replies: 7
    Last Post: 05-10-2009, 01:31 AM
  2. Keyboard Input
    By CaliJoe in forum C++ Programming
    Replies: 3
    Last Post: 05-08-2009, 09:51 AM
  3. Keyboard input in a Dialog
    By ksarkar in forum C++ Programming
    Replies: 1
    Last Post: 05-20-2005, 05:39 AM
  4. Intercepting keyboard input
    By EvBladeRunnervE in forum Windows Programming
    Replies: 3
    Last Post: 01-08-2004, 09:03 AM
  5. FAQ Keyboard Input ? (C++)
    By Malikive in forum FAQ Board
    Replies: 6
    Last Post: 11-07-2001, 09:30 PM