1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

reading arrow keys

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

  1. Colin Mac

    Colin Mac New Member

    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

    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

  4. DaWei

    DaWei New Member

    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