Arrow keys in console?

This is a discussion on Arrow keys in console? within the C++ Programming forums, part of the General Programming Boards category; I knwo how to use gotoxy(x, y) but how do I detect an arrow key using console?...

  1. #1
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question Arrow keys in console?

    I knwo how to use gotoxy(x, y) but how do I detect an arrow key using console?

  2. #2
    Banned frenchfry164's Avatar
    Join Date
    Oct 2001
    Posts
    1,552
    Code:
    #define leftarrow 'K'
    #define uparrow 'H'
    #define downarrow 'P'
    #define rightarrow 'M'
    
    getch();
    
    if (getch()==leftarrow)
    {
    ...
    ...
    }
    Hopefully that will work, if not, reply. It works for me, I'm using DJGPP BTW.

  3. #3
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Unhappy That didn't work...

    That didn't work. I am using Bloodshed Dev-C++ 4/4.01 compiler.
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: trifaze_mattu@lycos.com

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    For the gotoxy() in a console;

    FAQ - Various

    For the <- and -> keys, I guess you would need to somehow read WM_KEYUP messages and respond to VK_LEFT and VK_RIGHT, but in a console this would not be easy........ If you want edited input in your program I guess you would be better off with an editbox in a Win32 Application.

    Out of interest, what are you trying to do

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Movement with arrow keys
    By louis_mine in forum C Programming
    Replies: 3
    Last Post: 02-06-2005, 03:35 PM
  2. Interfacing with arrow keys...
    By adityakarnad in forum Game Programming
    Replies: 1
    Last Post: 08-30-2003, 10:25 PM
  3. msdos arrow keys?
    By seditee in forum Game Programming
    Replies: 3
    Last Post: 05-07-2002, 11:29 PM
  4. Arrow keys
    By Nutshell in forum C Programming
    Replies: 5
    Last Post: 03-27-2002, 10:49 AM
  5. Reading Arrow keys from console
    By D in forum C Programming
    Replies: 5
    Last Post: 02-22-2002, 03:46 PM

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