Click to See Complete Forum and Search --> : how to write this c program


srikanth123456
February 5th, 2007, 10:43 PM
hi,
i need to write a "c" program that

when i press a key on keyboard of PC, it should reply in the output

saying that "key is pressed"

and if the key is hold for more than 350ms it should reply that

"the key is hold"


can u help me by giving some tips for this program

dude_1967
February 6th, 2007, 03:11 PM
If you are restricted to the C language, then the first part can be done with simple C input / output using functions such as printf(...) and scanf(...) defined in the header <stdio.h>.

For the second part with the exact timing of 350ms, there is no real language support for these kinds of measurements. In addition, the keyboard itself has hardware settings for the repeat function. This all makes this kind of stuff a bit tricky. Can you further explain your target environment for the second part of the question?

Chris.

humptydumpty
February 6th, 2007, 10:12 PM
hi,
i need to write a "c" program that

when i press a key on keyboard of PC, it should reply in the output

saying that "key is pressed"

and if the key is hold for more than 350ms it should reply that

"the key is hold"


can u help me by giving some tips for this program

have a look in MSDN for getch() and kbhit()

Thanx