Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!snorkelwacker.mit.edu!paperboy!meissner From: meissner@osf.org (Michael Meissner) Newsgroups: comp.unix.programmer Subject: Re: How do you read the arrow keys? Message-ID: Date: 28 Dec 90 17:39:23 GMT References: <3080@dali> Sender: news@OSF.ORG Organization: Open Software Foundation Lines: 108 In-reply-to: icsu7039@nero.cs.montana.edu's message of 27 Dec 90 19:20:24 GMT I tried mailing to icsu7039@nero.cs.montana.edu, but got a mail bounce: | From: icsu7039@nero.cs.montana.edu (Spannring) | Newsgroups: comp.unix.programmer | Date: 27 Dec 90 19:20:24 GMT | Organization: Montana State University, Dept. of Computer Science, Bozeman | | | I am currently porting some menu routines from MS-DOG to Unix. | What is the proper (terminal independent) way of reading the arrow | and/or function keys? If your vendor's curses package is based on System V.2 then that is provided. If you have the old broken BSD curses, lots of luck -- you can read what the function keys send with tgetstr and the capabilities kd, ku, kl, and kr for the arrow keys -- you will have to do the parsing yourself. Quoting from the manual on curses: int getch ( void ); Get a character from stdscr. May be used with mini- curses. The following function keys might be returned by the getch() function if keypad() has been enabled: KEY_BREAK Break key (unreliable) KEY_DOWN Down arrow key KEY_UP Up arrow key KEY_LEFT Left arrow key KEY_RIGHT Right arrow key KEY_HOME Home key KEY_BACKSPACE Backspace (unreliable) KEY_F(n) Function key Fn, where n is an integer from 0 to 63 KEY_DL Delete line KEY_IL Insert line KEY_DC Delete character KEY_IC Insert character or enter insert mode KEY_EIC Exit insert character mode KEY_CLEAR Clear screen KEY_EOS Clear to end of screen KEY_EOL Clear to end of line KEY_SF Scroll one line forward KEY_SR Scroll one line backwards (reverse) KEY_NPAGE Next page KEY_PPAGE Previous page KEY_STAB Set tab KEY_CTAB Clear tab KEY_CATAB Clear all tabs KEY_ENTER Enter or send (unreliable) KEY_SRESET Soft (partial) reset (unreliable) KEY_RESET Reset or hard reset (unreliable) KEY_PRINT Print or copy KEY_LL Home down or bottom (lower left) KEY_A1 Upper left key of keypad KEY_A3 Upper right key of keypad KEY_B2 Center key of keypad KEY_C1 Lower left key of keypad KEY_C3 Lower right key of keypad Due to lack of definitions in terminfo, or due to the terminal not transmitting a unique code when the key is pressed, not all of these keys are supported. ... int keypad( WINDOW *win, bool bool_flag ); Enable keypad input on window win if bool_flag is true. -- Michael Meissner email: meissner@osf.org phone: 617-621-8861 Open Software Foundation, 11 Cambridge Center, Cambridge, MA, 02142 Considering the flames and intolerance, shouldn't USENET be spelled ABUSENET?