Proccessing Arrow Key Input

This is a discussion on Proccessing Arrow Key Input within the Windows Programming forums, part of the Platform Specific Boards category; This may be a stupid question, but should the arrow keys trigger a WM_KEYDOWN message? They aren't in my program, ...

  1. #1
    Registered User Xzyx987X's Avatar
    Join Date
    Sep 2003
    Posts
    107

    Proccessing Arrow Key Input

    This may be a stupid question, but should the arrow keys trigger a WM_KEYDOWN message? They aren't in my program, so I was wondering if that is correct behavior. Also, if it is correct then how do you usually check if they're pressed?

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,805
    1)That should trigger a WM_KEYDOWN message
    2)You can use VK_LEFT,VK_RIGHT,etc...
    check this link for a download of the win32 manual it helps ALOT
    http://ftgu.thejefffiles.com/downloads.php
    [edit] oh and if you get the help file check for the keyboard stuff under Processing Keystroke Messages[/edit]
    Last edited by prog-bman; 06-21-2004 at 12:35 AM.
    Woop?

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    It the application Win32 API or MFC?

    Kuphryn

  4. #4
    Registered User Xzyx987X's Avatar
    Join Date
    Sep 2003
    Posts
    107
    Quote Originally Posted by prog-bman
    1)That should trigger a WM_KEYDOWN message
    2)You can use VK_LEFT,VK_RIGHT,etc...
    check this link for a download of the win32 manual it helps ALOT
    http://ftgu.thejefffiles.com/downloads.php
    [edit] oh and if you get the help file check for the keyboard stuff under Processing Keystroke Messages[/edit]
    I was already using the Win32 API reference that came with the Platform SDK. The document you linked me to seems to be pretty much the same thing as the one I was using.
    Quote Originally Posted by kuphryn
    It the application Win32 API or MFC?

    Kuphryn
    It's Win32 API.

    The weird thing is, the window recieves a WM_KEYDOWN on every key that's supposed to trigger one except the arrow keys. One thing I probobly should've mentioned before is that the window that's supposed to recieve the input is actually a control inside another window. The parent window isn't recieving a WM_KEYDOWN on the arrow keys either though, so I dunno if that has anything to do with it.

  5. #5
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Interesting.

    One solution is a keyboard hook. Check out SetWindowsHook() and SetWindowsHookEx().

    Kuphryn

  6. #6
    Registered User Xzyx987X's Avatar
    Join Date
    Sep 2003
    Posts
    107
    Yup, that did the trick. Thanks for the help. It's weird that I'd have to set things up that way...

  7. #7
    Registered User Xzyx987X's Avatar
    Join Date
    Sep 2003
    Posts
    107
    Uh, one short follow up question. Is there any way to send information into the KeyboardProc function (such as the hook handle) without using a global variable? In this case if I were to use a global variable it would cause some annoying complications.

  8. #8
    Semi n00b Mithoric's Avatar
    Join Date
    Jun 2003
    Posts
    293
    I keep track of key presses using an bool array, just set the wParam index in the array to true on key down and false on key up..

  9. #9
    Registered User
    Join Date
    Jun 2004
    Posts
    84
    Quote Originally Posted by Xzyx987X
    The weird thing is, the window recieves a WM_KEYDOWN on every key that's supposed to trigger one except the arrow keys.
    Wery weird... well, you can check if arrow keys does not trigger WM_SYSKEYDOWN message just to be sure.

  10. #10
    Registered User Xzyx987X's Avatar
    Join Date
    Sep 2003
    Posts
    107
    Ok, here are a few more details that may explain things. First of all, I tried to intercept the WM_SYSKEYDOWN message, and the only message that tripped it after I pressed every key on the entire keyboard was the alt key. Another interesting thing that I didn't notice before because my speakers were off, whenever I press a charector key when the control has focus I get the default windows beep sound. Lastly, when I had the keybord input set up to be recived through a hook process, it gave me two key presses forevery single key I typed. Anyone know what's wrong now?

  11. #11
    Registered User Xzyx987X's Avatar
    Join Date
    Sep 2003
    Posts
    107
    Since this seems to be such a difficult problem I'll post the full source code to the control. You won't be able to compile it without the my other code libraries though, so if you really need those to tell what wrong let me know and I can post those too. Also, even though it's only about 2/3 done at this point feel free to offer feedback about ways it could be improved.
    Attached Files Attached Files

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Arrow Key
    By peckitt99 in forum Windows Programming
    Replies: 2
    Last Post: 03-24-2007, 05:00 AM
  2. Menu Bar(using arrow key)
    By SweeLeen in forum C++ Programming
    Replies: 1
    Last Post: 09-28-2005, 11:23 PM
  3. Arrow key reading
    By sufthingol in forum C++ Programming
    Replies: 5
    Last Post: 03-19-2005, 03:08 PM
  4. key input definition
    By hkmixxa in forum C++ Programming
    Replies: 3
    Last Post: 08-09-2004, 05:39 PM
  5. single key input
    By SPiRiToFCaT in forum C++ Programming
    Replies: 14
    Last Post: 11-15-2002, 01:23 PM

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