Thread: Up/down arrows

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    16

    Up/down arrows

    Hi! I have a small piece of code that checks the number (code) of an inputted character and later, for example, prints something. My idea is for the user to be able to navigate through the display only with the up and down arrows, and now this code:

    Code:
    do {
    c = getch();
    }
    while (c!=0);
    
    if(c==0)
    {
    c = getch(); // retrieve second byte of extended code
    c *= 256; // shift left by 8 bits to get extended code
    printf( "Extended keystroke: %X\n", c );
    }
    The problem is that it will check if the first byte is 0, however I don't know if it's possible to limit the pressing of buttons like End, Pg Dn, Home, Pg Up etc... ? I can write after this: if (c==0x4800) printf("up"); else if (c==0x5000) printf("down"); Perhaps it's an easy task and I just need some rest before finishing this, but the fact is that at this moment I have no solution. Glad, if you could help.
    Last edited by nowber; 10-30-2009 at 04:47 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to use arrows
    By wyvern in forum C++ Programming
    Replies: 9
    Last Post: 10-12-2005, 01:19 PM
  2. Directional arrows
    By Ian Paice in forum C Programming
    Replies: 4
    Last Post: 07-31-2003, 07:57 AM
  3. up, down, left, right arrows
    By revelation437 in forum C Programming
    Replies: 10
    Last Post: 12-12-2002, 09:38 AM
  4. Using Arrows in Win32 Console
    By GreenCherry in forum C++ Programming
    Replies: 2
    Last Post: 10-04-2002, 11:27 AM
  5. Arrows
    By 14n in forum C++ Programming
    Replies: 4
    Last Post: 10-02-2002, 11:30 PM