CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2006
    Posts
    13

    Lightbulb how to write this c program

    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

  2. #2
    Join Date
    Jun 2002
    Location
    Germany
    Posts
    1,557

    Re: how to write this c program

    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.
    Last edited by dude_1967; February 6th, 2007 at 04:12 PM. Reason: clarity
    You're gonna go blind staring into that box all day.

  3. #3
    Join Date
    May 2005
    Location
    Oregon
    Posts
    3,725

    Re: how to write this c program

    Quote Originally Posted by srikanth123456
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured