Keyboard input

This is a discussion on Keyboard input within the Windows Programming forums, part of the Platform Specific Boards category; would it be efficient to use GetKeyState(), to determine the input the user presses or is there another method. My ...

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

    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,546
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Oct 2006
    Location
    New York
    Posts
    123
    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,546
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  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
    123
    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,189
    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.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  8. #8
    Registered User
    Join Date
    Oct 2006
    Location
    New York
    Posts
    123
    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, 08:03 AM
  5. FAQ Keyboard Input ? (C++)
    By Malikive in forum FAQ Board
    Replies: 6
    Last Post: 11-07-2001, 08:30 PM

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