another basic question on keyboard input

This is a discussion on another basic question on keyboard input within the C++ Programming forums, part of the General Programming Boards category; Ok, here it goes another pocket question... sorry for posting questions about basic stuff... in a windows console aplication, how ...

  1. #1
    Registered User
    Join Date
    Feb 2004
    Posts
    42

    another basic question on keyboard input

    Ok, here it goes another pocket question...
    sorry for posting questions about basic stuff...

    in a windows console aplication, how can i make a menu that works with instant key pressing. I mean, i usualy use cin (console input) but it takes pressing the key and pressing return. how can i make it work only with one key pressing.

    like "press Q to quit"... and then, the moment i would press Q the program would quit at once without needing me to press return...

    hope the english is ok

  2. #2
    *this
    Join Date
    Mar 2005
    Posts
    498
    Well, this can't be done with standard c++ headers, but if your compiler supports it, include <conio.h>

    Here would be an example:

    Code:
    int choice;
    cout << "[1]Play    [2]Exit";
    choice = getch();

  3. #3
    Registered User
    Join Date
    Feb 2004
    Posts
    42

    so easy

    Thks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. basic question about global variables
    By radeberger in forum C++ Programming
    Replies: 0
    Last Post: 04-06-2009, 01:54 AM
  2. Trouble with a lab
    By michael- in forum C Programming
    Replies: 18
    Last Post: 12-06-2005, 11:28 PM
  3. Input Validation Question
    By zackboll in forum C Programming
    Replies: 14
    Last Post: 10-12-2004, 01:05 AM
  4. File input question
    By Beast() in forum C Programming
    Replies: 16
    Last Post: 07-09-2004, 04:23 PM
  5. FAQ Keyboard Input ? (C++)
    By Malikive in forum FAQ Board
    Replies: 6
    Last Post: 11-07-2001, 09:30 PM

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