[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finer keystroke detection

From: George Andreou
Subject: Re: Finer keystroke detection
Date: Tue, 11 May 2004 21:46:27 +0300
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4

Steve Litt wrote:

Hi all,

I've looked thru ncurses.h, and through man terminfo, and various other docuemntation, and for the life of me I cannot find how to detect things like Ctrl+Enter, Ctrl+F3, etc. These would be VERY handy for an app I'm writing.

I even wrote a keystroke detection program to print out the value of keystrokes as I type, and according to that program, Enter, Shift+Enter and Ctrl+Enter are identical. According to my program, the alt and Ctrl keys have no modification effect on function keys etc.

Could you tell me how to use Curses to make these distinctions?

Hi Steve,

I believe man curs_inopts is well documented, you can use several routines from
there to achieve your goal.

For example you can play with halfdelay() in a way where you will trigger the call of a new function to capture a second keyboard event or a third keyboard event, etc (you can even write a recursive function), so that you can collect all the keys.

Hint: you might need to call raw() / noraw() / cbreak() / nocbreak() between the capture of two consecutive control characters. Watch out, how these routines alter the behavior of the others (at the same man page).

Well the above is just an idea, I havent written this type of code yet. I hope this can help you.

Below my sig is the detection program I used.



Steve Litt
Author: * Universal Troubleshooting Process courseware
  * Troubleshooting Techniques of the Successful Technologist
  * Rapid Learning: Secret Weapon of the Successful Technologist
  * Troubleshooters.Com
  * http://www.troubleshooters.com

#include <form.h>

int main()
        int ch;
        keypad(stdscr, TRUE);
        while((ch = getch()) != KEY_F(1))
                mvwprintw(stdscr, 10,1,"                                          
                mvwprintw(stdscr, 10,1,"You pressed char %c, number %ld", ch, 

        return 0;

Bug-ncurses mailing list

George Andreou
Student of Applied Mathematics, University of Crete at Heraklion
Tel (+30) 2810 326211
ICQ UIN: 83893560

reply via email to

[Prev in Thread] Current Thread [Next in Thread]