How do I code for a key press? Where does the code go?
Thx for the help!
DW
How do I code for a key press? Where does the code go?
Thx for the help!
DW
sorry .. i didnt get you what do you mean by key press?
is it in cosole programming??
if you mean to press input you can use getch() ... i hope that you mean
There is no standard way to do this. See the Programming FAQ. The C++ language standard expects you to type something in, and then hit ENTER. A standard-compliant program can work with a system that doesn't transfer data until ENTER is pressed.
My compiler (Microsoft) includes kbhit() (keyboard hit). I think it's in <conio>. kbhit() returns zero if a key has not been pressed (or if the keyboard buffer is empty). It returns non-zero if a key has been pressed. So, you usually use it in a loop with an if-statement: if(kbhit() )... or, if(!(kbhit() ));
Last edited by DougDbug; 03-23-2004 at 06:45 PM.
Ah, sorry. Not in a console app. In a windows app.
Borland c++ builder 6
cheers
Ummm... I think you need a Windows book. I don't have it with me, but the standard book is Programming Windows, by Charles Petzold. I also don't remember the exact function(s). But, the code goes in your main Windows Processing Loop. When you press a key, move or ckick your mouse, the operating system sends a message to your program. You can capture or ignore these messages.
II've never used Borlad Builder, but I'm sure it has an "easy" way of generating the code for processing keystrokes. Every Windows program has to do it!