reading arrow keys

Colin Mac's Avatar, Join Date: Jan 2007
Go4Expert 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?
0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
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.
0
Colin Mac's Avatar, Join Date: Jan 2007
Go4Expert Member
OK, I'm running XP with a Basic 104 Dell keyboard, same as this one
http://images.moditory.com/reviews/Dell/MVC-003F.JPG
0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
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.