Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 329097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:33:23+00:00 2026-05-12T09:33:23+00:00

I am working on a simple console app to get my feet wet with

  • 0

I am working on a simple console app to get my feet wet with curses again. I am having a bit of a problem porting my app from xp to AIX. Here is a sample chunk of code.

int main(void)
{
    WINDOW *_window = initscr(); 
    int _rows;
    int _cols;

    cbreak();

    /* Accept all keys */ 
    keypad(_window, true);

    /* Don't echo things that are typed */ 
    noecho();

    /* Get the screen dimensions */ 
    getmaxyx(_window, _rows, _cols);

    /* Don't display cursor */ 
    curs_set(0);

    for (;;)
    {
        printw("Press a Key ");
        refresh();
        int key = wgetch(_window);
        printw("%d \n", key);
    }

    endwin();

    return 0;
}

When I run this under XP, I get the following output from a DOWNARROW followed by a CTRL-DOWNARROW.

Press a Key 258
Press a Key 481
Press a Key

Suggesting 258 is the code for the down arrow, and 481 for ctrl-down arrow.

Performing this same test under AIX.

Press a Key 1858
Press a Key 27
Press a Key 79
Press a Key 66
Press a Key

The 1858 is the down arrow, and the 27/29/66 is the response for the ctrl-down arrow.
I recognize that the 27/29/66 is probably one of the standard escape sequences.
I was hoping that curses would map it to a single value. The XP side has a CTL_DOWN defined in the curses.h file. The AIX side does not.

So my question here is

Is them some incantation I missed here, that will magically map those three character into a nice unique integer? or do I have to write a class of some sort, to handle hiding the platform specific keystrokes into something my real app can use?

My eyes are blood shot from searching the AIX online stuff.
Any help to point me in the correct direction would be appreciated.

Other random information

I am running xp pro, with the latest service packs
msvc 6, with service pack 6. The curses library is pdcurses

The other compiler is IBM XL C/C++ ENTERPRISE EDITION V8.0
The compile uses

xlc++ -g app.cpp -lcurses

I am using pdcurses33 on the pc
and the native curses on AIX.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:33:23+00:00Added an answer on May 12, 2026 at 9:33 am

    Re: [PDCurses] Alt + Shift + n (for example) on Windows

    LM
    Fri, 12 Jul 2002 08:13:53 -0700

    At 7/7/2002 6:10:00 PM, Jeremy Smith wrote:

    I have run into a bit of a problem. I use the Curses function getch() in
    my program, for keys such as ‘n’ or Alt+’n’ but how do I detect these
    combinations:

    Ctrl+n
    Alt+Shift+n
    Ctrl+Alt+n
    Ctrl+Alt+Shift+n

    I imagine there must be some kind of flag to return Shift+Alt+2 as an
    actual keycode (which is different from Shift, Alt or 2), but I don’t
    know how. 🙁

    I checked the header for file for curses.h and they appear to list all the
    standard scan codes you can get back from a keyboard, including some ALT
    combinations and a few of the Control combinations.

    Then I checked the Windows implementation for getting a character. In
    pdckbd.c the routine win32_kbhit calls ReadConsoleInput. The shift, alt,
    control and other status keys are returned from this function in the
    dwControlKeyState. The PDC_get_bios_key reports what key is pressed using
    the two kptab tables (kptab and ext_kptab), so if the combination is not
    in the table, you probably aren’t seeing it. You may be able to add some
    definitions to the tables if something is missing. There’s also some code
    in the same routine that sets the states (BUTTON_SHIFT, BUTTON_CONTROL,
    BUTTON_ALT), but this appears to be for mouse input. So you can check
    these keys in the MOUSE_STATUS structure. This only pertains to the
    Windows implementation. Every platform has a unique way of figuring out
    which keys are pressed.

    In 16 bit DOS, I used to change the state of shift, caps lock and num lock
    by changing the settings at the hex 417 address. This only works for real
    mode programs. Many of the new Windows compilers don’t even allow you to
    access bios or memory directly with functions any more. The 16 bit
    location at hex 417 and hex 418 indicates that the right shift has been
    pressed by setting the highest bit at the 417 address, the left shift, by
    setting the second highest bit in the byte, the ctrl key by setting the
    next highest and the alt key by the next highest after that. The 418
    address holds the status of whether or not the right or left alt and
    control keys were pressed.

    It appears as though you may have to make some modifications to your
    particular version of curses to get exactly what you want. Curses is a
    very portable user interface, thus it often supports the lowest common
    denominator of features on some platforms.

    By the way, I remember reading that there was work underway for a new
    curses standard that included international character support. Has anyone
    heard anything further on this effort?

    Best wishes.

    Laura Michaels
    http://www.distasis.com

    It looks like i need to do my own keyboard decoding.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a simple url-shortening app and have the following express routes: app.get('/',
I'm still working on my little Tkinter project which is simple a logging console
Working on a simple TimeTracker App. You start a timer, wait a certain time,
im working on a simple game like space invaders,and i got into a problem.
I'm working on a simple webservice in django. This is my first web app
I am making this simple get request using jquery ajax: $.ajax({ url: https://app.asana.com/-/api/0.1/workspaces/, type:
I have been working on the app engine for some time, and this problem
I've just written a simple FTP console app to upload files on a local
I've written a simple console app which uses JPA to connect to a MySQL
I am working on a fairly simple demo app. Three input dropdown boxes are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.