Thread: key press

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    16

    Question key press

    before i started learning c++ i learned visual basic and in it there was a type of thing to do key press how do i do it in c++ to where its like

    cout<<"Enter commmand"<<endl;
    //user presses a
    cout<<"You enterd a"<<endl;

    something like that
    • 0927
    • a.k.a 0 9 two 7

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    85
    #include <iostream.h>
    #include <stdlib.h>
    #include <conio.h>
    int main()
    {
    char key;
    key=getch();
    cout<<"you entered "<<key<<endl;
    system("PAUSE");
    return 0;
    }

  3. #3
    A Banana Yoshi's Avatar
    Join Date
    Oct 2001
    Posts
    859
    or this...

    #include<stdio.h>
    #include<iostream.h>

    main(){
    cout << "Enter a character: ";
    getche();
    }

    //the getche() function automatically outputs the pressed character to the screen.
    Yoshi

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, 04:42 PM
  4. FAQ: Directional Keys - Useing in Console
    By RoD in forum FAQ Board
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM