inputing keys

This is a discussion on inputing keys within the C++ Programming forums, part of the General Programming Boards category; Code: #include <curses.h> int main(int argc, char *argv[]) { initscr(); raw(); int a = getch(); printf(%d, a); getch(); endwin(); return ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    26

    inputing keys

    Code:
    #include <curses.h>
    
    int main(int argc, char *argv[])
    {
      initscr();
      raw();
    
      int a = getch();
    
      printf(%d, a);
    
      getch();
    
      endwin();
      return 0;
    }
    i need to input a key and print not the char but the hex or octal code so that i can determine the code for the esc key.

    i want my getch() command to respond to the esc key, but it does not seem to when i use \1B

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,788
    Code:
    printf("Oct: %o Hex: %x\n",a,a);
    Or, since this is the C++ board:

    Code:
    #include <iostream>
    #include <iomanip>
    
    ...
    
    std::cout << "Oct: " << std::oct << a << " Hex: " << std::hex << a << std::endl;
    Last edited by hk_mp5kpdw; 03-16-2005 at 10:31 AM.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simulate Keys with a Keyboard Hook
    By guitarist809 in forum Windows Programming
    Replies: 3
    Last Post: 11-14-2008, 07:14 PM
  2. blocking or passing keys with global hook
    By pmouse in forum Windows Programming
    Replies: 4
    Last Post: 08-29-2007, 02:54 PM
  3. Movement with arrow keys
    By louis_mine in forum C Programming
    Replies: 3
    Last Post: 02-06-2005, 03:35 PM
  4. Interfacing with arrow keys...
    By adityakarnad in forum Game Programming
    Replies: 1
    Last Post: 08-30-2003, 10:25 PM
  5. Arrow Keys and Such
    By Thantos in forum Game Programming
    Replies: 5
    Last Post: 10-25-2001, 05:40 PM

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