Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Arrow Key inputs - HELP

  1. May 1, 2007 #1
    Arrow Key inputs - HELP!!!

    hi. I'm 14 years old and have been programming for a year now. I have now however,come to a point where i need help. I'm using visual studios if that helps. I also program in C++. I have been needing to find out how to use the arrow keys as an input. For instance....When you press the left arrow button, a picture pox moves left etc. Thanks for any help. Alastair
  2. jcsd
  3. May 1, 2007 #2
    wow 14? ...search for ASCII values/chart (128 or 256 values)
    They should have the arrow key values in them (though it may depend on the type of you keyboard you have).

    what are you using as your graphics display? .net/mfc?
  4. May 1, 2007 #3
    yep, Only 14. I think the graphics is .net but not sure...how do you tell? do you know the code for the arrow key inputs? Thanks. Alastair
    Last edited: May 1, 2007
  5. May 1, 2007 #4


    User Avatar
    Science Advisor
    Homework Helper

    You don't say what language you are using in visual studio.

    If it is VB then this is simple.
    Set KeyPreview property of the form to true.
    The arrow keystokes will be available in the forms KeyDown or KeyUp function. The only key not available is TAB key.

    If C++ then I think this can be done with the Classwizzard.
    I never wrote a GUI in C. Just .dlls and UNIX command line code, so I'm not sure.
    Worst case here is to set up an event callback with some calls to kernal32.
    Try looking in the samples directory.
  6. May 2, 2007 #5
    Thanks mate. Normally, i program in C++ but i do know a small bit of VB too.
  7. May 2, 2007 #6
    i think anytime you use form its .net and if you use winapp/document/doctemplate/view/framewnd its MFC.

    for arrows keys...you can write a simple program to receive character inputs(cin/scanf) and then output the character as hex(%h or x?) or decimal(%d)

    it depends on how you are receiving your inputs...and as notime said u can probably access by using classwizard...i'm pretty sure the GUI command is OnKeyChar. or OnKeyPress/Release in MSVC.

    search in the environment help...but you may still have to find the ascii or keyboard number.

    u can try this
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?

Similar Discussions: Arrow Key inputs - HELP
  1. Key error on python (Replies: 0)