reading arrow keys

Discussion in 'C' started by Colin Mac, Mar 3, 2007.

  1. Colin Mac

    Colin Mac New Member

    Joined:
    Jan 21, 2007
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    I want to make a C program that will read in the arrow keys. I see they don't have ascii codes. Can someone explain how I could go about it?
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    This is entirely implementation dependent, as regards both hardware platforms and operating systems. You don't mention any of those things. Keyboards put out hardware signals; between there and you, a number of people mess with them in quite different ways.
     
  3. Colin Mac

    Colin Mac New Member

    Joined:
    Jan 21, 2007
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
  4. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    You can start here. If that seems too much of an overview, drill down to low-level input. Essentially, every keypress generates a signal which is mapped into a virtual key code. Intervening software, such as your C/C++ run-time libraries will deal with these and give you the somewhat limited functions that you have there. You can deal with them directly. In addition to getting the codes, or reacting with key events, you can also deal with such things as key repeat and mouse events. The conio functions that you find with some compilers, such as Dev-Cpp, base their rawer functions on this API, while modeling them after the old Turbo C stuff.

    Even though Windows doesn't have the nice signalling functions that one finds in Unix, you can pick up on events like someone clicking the big 'X', or logging off, or whatever, and try to gracefully shut down your program.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice