Thread: keyboard control

  1. #1
    Registered User MathFan's Avatar
    Join Date
    Apr 2002
    Posts
    190

    keyboard control

    if u r using bc++b these are predefined to VK_LEFT, VK_RIGHT and so on...
    otherwise, this should help:
    #define LEFT_TEXT 0
    #define CENTER_TEXT 1
    #define RIGHT_TEXT 2
    #define BOTTOM_TEXT 0
    #define TOP_TEXT 2
    #define NORM_WIDTH 1
    #define THICK_WIDTH 3
    #define DOTTEDLINE_LENGTH 2
    #define CENTRELINE_LENGTH 4
    #define USER_CHAR_SIZE 0
    #define MAXCOLORS 15
    #define CLIP_ON 1
    #define CLIP_OFF 0
    #define TOP_ON 1
    #define TOP_OFF 0

    // Definitions for the key pad extended keys are added here. I have also
    // modified getch() so that when one of these keys are pressed, getch will
    // return a zero followed by one of these values. This is the same way
    // that it works in conio for dos applications.
    // M. Main -- Nov 3, 1998
    #define KEY_HOME 71
    #define KEY_UP 72
    #define KEY_PGUP 73
    #define KEY_LEFT 75
    #define KEY_CENTER 76
    #define KEY_RIGHT 77
    #define KEY_END 79
    #define KEY_DOWN 80
    #define KEY_PGDN 81
    #define KEY_INSERT 82
    #define KEY_DELETE 83
    #define KEY_F1 59
    #define KEY_F2 60
    #define KEY_F3 61
    #define KEY_F4 62
    #define KEY_F5 63
    #define KEY_F6 64
    #define KEY_F7 65
    #define KEY_F8 66
    #define KEY_F9 67

    void main ()
    {char ch=0;
    ch=getch();
    switch(ch)
    {case KEY_LEFT:
    //....................
    }
    }

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Eh, what's the question?

    ...and it's better to do this:

    if(kbhit()) ch=getch();

    Then it won't attempt to take the value of getch() unless a key have been pressed.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using threads for control input (keyboard, serial)
    By synthetix in forum C Programming
    Replies: 1
    Last Post: 07-06-2009, 07:43 PM
  2. Control and Keyboard Input
    By Almina in forum C++ Programming
    Replies: 6
    Last Post: 07-30-2008, 10:01 AM
  3. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  4. sending something to a rich edit control without keyboard
    By RancidWannaRiot in forum Windows Programming
    Replies: 1
    Last Post: 11-21-2005, 08:53 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM