On Linux using NCurses (version 5.9) the keys KEY_SLEFT and KEY_SRIGHT are defined, however KEY_SUP and KEY_SDOWN are missing.
Since I have Windows and PDCurses installed on the same computer, I saw that with PDCurses all shifted arrow keys are defined.
I opened "curses.h" and noted down their definitions this is what my notes look like:

  KEY         LINUX (NCurses)   WINDOWS (PDCurses)
KEY_DOWN        0402 (=258)        0x102 (=258)
KEY_UP          0403 (=259)        0x103 (=259)
KEY_LEFT        0404 (=260)        0x104 (=260)
KEY_RIGHT       0405 (=261)        0x105 (=261)
KEY_SUP         MISSING!!!         0x223 (=547)
KEY_SDOWN       MISSING!!!         0x224 (=548)
KEY_SLEFT       0611 (=393)        0x187 (=391)
KEY_SRIGHT      0622 (=402)        0x190 (=400)

As you can see from this table, the normal arrow key definitions match on both platforms.
However 2 shifted keys are missing on Linux and the other 2 aren't the same number - on Linux they are increased by 2.
I tried adding #define KEY_SUP 0x223 , #define KEY_SUP 547 , #define KEY_SUP 549 , but none of these worked.
Has anybody got a solution?
Your distro might be broken there. You might want to go complain on their site.

Before you do, though, you might want to set up a keylogger and figure out exactly what the codes are that your xkbd is sending through to ncurses. Once you do, you can update your terminfo database and curses.h, and tell those you complain to how to do it....

Hope this helps.
Normally shift left/right refers to the left or right shift buttons, not the combination of shift + arrow keys. I have no idea what shift up/down are though, so perhaps I m mistaken.
Holy crap, that's right!

ModShop +1

[edit] /me forgot everything! /me goes off to cry
Last edited on
I see your point there. This means SLEFT and SRIGHT on Linux refer to the shift buttons like ModShop said, but on Windows they mean a combination of shift + arrow key. Any way to capture shifted arrow keys on Linux?
OK, so I looked it up. (Because PDCurses and NCurses should not differ in the definition of the key code.)

KEY_SLEFT is the shifted left arrow key.

So the answer is: it isn't designed to do that.
You'll have to enable extended keys and watch for a shift key then an arrow key.

Good luck!
Topic archived. No new replies allowed.