Results 1 to 2 of 2

Thread: Test for Key press

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2002
    Posts
    21

    Test for Key press

    Im a complete newbie at C++

    I have created an object using a constructor. When an object is created a message is displayed on screen. I want to be able to display this message on the screen until a user presses a key before the program returns to main.

    In the main i have
    void main()
    {
    object new_object("Display This");

    object2 new_object2;

    new_object2.afunction();
    }

    The constructor code is

    object:bject(char adsupplied[])
    {
    while(??)
    {
    cout << text<<endl;
    }
    }

    I know a need a while loop in the constructor but do not now how to detect if a key is pressed.

    Any help would be appreciated

  2. #2
    Lively Member
    Join Date
    Oct 2001
    Posts
    80
    -=conio.h=-
    kbhit() - check if a keystroke is avaliable
    getch() - get the keypress

    -=bios.h=-
    bioskey(3) - Check if modifiers were pressed (Shift, Alt ....)
    bioskey(1) - bios version of kbhit()
    bioskey(0) - bios version of getch()

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