Thread: Keyboard Input

  1. #1
    Unregistered
    Guest

    Keyboard Input

    I want to ask something about the keyboard input in Borland C++ v3.0. I wanted to ask how u get the input for arrowkeys..
    i-e what is their ascii values..?

  2. #2
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    the arrow keys return a scan code that is hardware dependant, also they are extended bit encoded - the first digit they return is a zero and then they return the scan code. To find out what code they return on your system write a key detector that gets the key loops back after a zero and prints the integer value.


    int check_key(); //begin checking function
    {
    int keypress; //holds the scan code of the keypress
    keypress=getch();//get the keypress
    if (keypress==0){check_key();}//check for extended key
    else
    cout<<keypress//print the scan code
    int wait = getch();//wait for a keypress
    }//end function

    call this from main,
    hope this helps
    Last edited by iain; 01-13-2002 at 05:03 PM.
    Monday - what a way to spend a seventh of your life

  3. #3
    A Banana Yoshi's Avatar
    Join Date
    Oct 2001
    Posts
    859
    try:

    int a;
    a=getch();
    cout << a;
    //loop
    Yoshi

  4. #4
    Registered User GrNxxDaY's Avatar
    Join Date
    Jul 2002
    Posts
    140
    do I have to include a special library class function header thingy? I try it in dev-c++4, and i get implicit declaration of getch()
    AOL: GrNxxDaY
    IDE: Dev-C++ Beta 5 (v4.9.4.1)
    Project: Eye of Sahjz (text-RPG)
    If you think I may need help, please IM me.

  5. #5
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I believe getch() is in conio.h.

  6. #6
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,138
    #include <mingw_conio.h> if conio.h doesn't work

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help using inline assembly for keyboard input
    By sleventeen in forum C Programming
    Replies: 7
    Last Post: 05-10-2009, 01:31 AM
  2. Keyboard Input
    By CaliJoe in forum C++ Programming
    Replies: 3
    Last Post: 05-08-2009, 09:51 AM
  3. Keyboard input in a Dialog
    By ksarkar in forum C++ Programming
    Replies: 1
    Last Post: 05-20-2005, 05:39 AM
  4. Intercepting keyboard input
    By EvBladeRunnervE in forum Windows Programming
    Replies: 3
    Last Post: 01-08-2004, 09:03 AM
  5. FAQ Keyboard Input ? (C++)
    By Malikive in forum FAQ Board
    Replies: 6
    Last Post: 11-07-2001, 09:30 PM