It is currently Tue, 07 Dec 2021 01:23:12 GMT



 
Author Message
 Processing arrow keys, function keys, etc.

This might be a stupid question, but here it goes.

I'm working on a program that needs to process arrow keys, function keys,
and other special keys -- if they are available. What is the best way of
determining if such keys are available on the user's terminal and, if so,
what sequence of characters I can expect when they are pressed?

I looked at the curses library, but that seems mostly interested in
terminal independent output. It appears to have little to say about input.
I also looked a little at the lower level stuff (terminfo, termcap), but
again the information I'm interested in doesn't seem to be discussed there
either.

Am I missing something here?

TIA

*****************************************************************************
Peter                                     http://www.**-**.com/ ~pchapin
pcha...@twilight.vtc.vsc.edu     Paganism: Ancient beliefs in a modern world



 Fri, 30 Jul 1999 03:00:00 GMT   
 Processing arrow keys, function keys, etc.

 Peter> This might be a stupid question, but here it goes.

 Peter> I'm working on a program that needs to process arrow keys,
 Peter> function keys, and other special keys -- if they are
 Peter> available. What is the best way of determining if such keys
 Peter> are available on the user's terminal and, if so, what sequence
 Peter> of characters I can expect when they are pressed?

You can get this info from termcap/terminfo.

 Peter> I looked at the curses library, but that seems mostly
 Peter> interested in terminal independent output. It appears to have
 Peter> little to say about input.  I also looked a little at the
 Peter> lower level stuff (terminfo, termcap), but again the
 Peter> information I'm interested in doesn't seem to be discussed
 Peter> there either.

The input sequences are just stored as string capabilities in the
terminal description (whether termcap or terminfo). You can read
the strings using the appropriate library functions (e.g. tgetstr).

Curses knows how to recognise these strings in keyboard input; if
you set keypad() true, then getch() will return values such as
KEY_UP or KEY_F(5) for the appropriate keys if they are used.
This is usually the easiest way.

HTH

--
Andrew.



 Sat, 31 Jul 1999 03:00:00 GMT   
 
   [ 2 post ] 

Similar Threads

1. Distinquishing escape key from arrow and function keys

2. Traping arrow keys or other special keys

3. arrow key function in CDE?

4. How to get Function/Arrow Keys? Source wanted

5. Function of Keys ALT-CTRL key combinations

6. Mapping keys other than the function keys

7. Need code for reading function keys AND naked escape key

8. Escape key timing issue and terminal function keys OSR5

9. Remapping Keys (want delete key to delete etc!)

10. OpenSSL Key Encryption/ Session Key/ etc


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software