Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   reading arrow keys (http://www.go4expert.com/forums/reading-arrow-keys-t3237/)

Colin Mac 4Mar2007 01:07

reading arrow keys
 
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?

DaWei 4Mar2007 03:47

Re: reading arrow keys
 
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.

Colin Mac 4Mar2007 04:47

Re: reading arrow keys
 
OK, I'm running XP with a Basic 104 Dell keyboard, same as this one
http://images.moditory.com/reviews/Dell/MVC-003F.JPG

DaWei 4Mar2007 09:42

Re: reading arrow keys
 
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.


All times are GMT +5.5. The time now is 07:02.