Key presses

This is a discussion on Key presses within the C++ Programming forums, part of the General Programming Boards category; I have not been able to find my book...what is the command for key presses again? Like if I press ...

  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    67

    Key presses

    I have not been able to find my book...what is the command for key presses again? Like if I press something a action happens

  2. #2
    Registered User
    Join Date
    Jul 2002
    Posts
    94
    "getch()"?

    I think that's in "conio.h"

    Brendan
    Draco dormiens nunquam titillandus

  3. #3
    Registered User
    Join Date
    Jul 2002
    Posts
    94
    Example:

    Code:
    int main()
    {
         int keyPress;
    
         cout << "Enter a number between 1 and 3: ";
         keyPress = getch();
    
         switch (keyPress)
         {
         case '1':
              cout << "You entered one!\n";
              break;
         case '2':
              cout << "You entered two!\n";
              break;
         case '3':
              cout << "You entered three!\n";
              break;
         default:
              cout << "Not a number between 1 and 3!\n";
              break;
         }
         return 0;
    }
    Brendan
    Draco dormiens nunquam titillandus

  4. #4
    Registered User
    Join Date
    Aug 2002
    Posts
    67
    Is there a certain resource file for that command harry? Cause it won't work with just i/o stream...Anyone?!?

  5. #5
    Registered User
    Join Date
    Jul 2002
    Posts
    94
    "conio.h"

    Brendan
    Draco dormiens nunquam titillandus

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 11-23-2007, 01:48 PM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  3. Directional Keys - Useing in Console
    By RoD in forum C++ Programming
    Replies: 38
    Last Post: 10-06-2002, 05:42 PM
  4. FAQ: Directional Keys - Useing in Console
    By RoD in forum FAQ Board
    Replies: 38
    Last Post: 10-06-2002, 05:42 PM

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