Key codes...

This is a discussion on Key codes... within the C++ Programming forums, part of the General Programming Boards category; what are the codes for the different keys on the board? or where could I find a list... oh and ...

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    75

    Key codes...

    what are the codes for the different keys on the board? or where could I find a list...

    oh and when I say codes I mean this type...

    0x38
    0x1c

    Thanks in advance...
    MSVC++~

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Make a program that prints the ascii value of the key you press.
    May be something like this (depends on your compiler):
    Code:
    while(something)
    {
       if(kbhit())
       {
          cout << (int)getch() << endl;
       }
    }
    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.

  3. #3
    Hardware Engineer
    Join Date
    Sep 2001
    Posts
    1,398

    ASCII table?

    Here's a link to an ASCII table: www.asciitable.com . You'll have to search a bit more to find the actual "key scan codes" i.e. If you want to know what the code for the num-lock is.
    Last edited by DougDbug; 03-18-2003 at 03:31 PM.

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >what are the codes for the different keys on the board? or where could I find a list...
    In a few days you can check the FAQ for a way to do it. Or you could search the boards, I'm sure the topic has come up. But since I'm nice, here is a (not really portable) function that you can use to test the codes with:
    Code:
    int get_code ( void )
    {
      int ch = getch();
    
      if ( ch == 0 || ch == 224 )
        ch = 256 + getch();
    
      return ch;
    }
    Just replace getch with your system's equivalent.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 11-23-2007, 12:48 PM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 09:00 AM
  3. Directional Keys - Useing in Console
    By RoD in forum C++ Programming
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM
  4. FAQ: Directional Keys - Useing in Console
    By RoD in forum FAQ Board
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM

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