keyboard keypress

This is a discussion on keyboard keypress within the Game Programming forums, part of the General Programming Boards category; the simple program below increments numbers until a key on the keyboard is hit. I want the program to increment ...

  1. #1
    Registered User
    Join Date
    Dec 2002
    Posts
    13

    keyboard keypress

    the simple program below increments numbers until a key on the keyboard is hit. I want the program to increment numbers while a key is pressed down by the user and to stop incrementing the numbers when the key (being the space bar) is no longer pressed down. please can someone help me out as im not sure how thats done.....thanks


    Code:
    #include <conio.h>
    #include <stdio.h>
    
    int main (void)
    {
      int sale;
      sale = 000.00;
    
       do{
          clrscr();
          printf("%d", sale);
          delay(150);
          sale += 0.01;
         }while(!kbhit());
    
       return 0;
    }

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Looks like a cross post to me.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Detecting keyboard and mouse in linux
    By sameer.nalwade in forum C Programming
    Replies: 3
    Last Post: 11-22-2008, 03:24 AM
  2. Keyboard port using other that a keyboard
    By antoinelac in forum C++ Programming
    Replies: 4
    Last Post: 06-12-2008, 02:46 PM
  3. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 09:00 AM
  4. What type of keyboard is this?
    By 7smurfs in forum Tech Board
    Replies: 5
    Last Post: 06-22-2005, 05:09 PM
  5. Game Design Topic #2 - Keyboard or Mouse?
    By TechWins in forum Game Programming
    Replies: 4
    Last Post: 10-08-2002, 03:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21