home *** CD-ROM | disk | FTP | other *** search
- /* * * * KBTEST.C * * * *
- Robin Anderson 10-3-92
- Test out keyboard characters in both dos & (sun) unix.
-
- Ah yes, the joy of "portable" C. Everything of any substance
- requires an OS specific function!
- ........................................................... */
-
- #include <stdio.h>
-
- #ifdef __TURBOC__
- #include <conio.h>
- #else
- #include <curses.h>
- #endif
-
- void
- main()
- {
- char ch;
-
- #ifndef __TURBOC__
- initscr( );
- cbreak( );
- noecho( );
- #endif
- ch = (char) 0;
- while ( ( ch != (char) 13) && ( ch != (char) 10) )
- {
-
- #ifdef __TURBOC__
- printf( "\nPress any key: ");
-
- /* read a char using turbo c "conio" routine: */
- ch = getch( ); /* no echo, may return 0 for extended codes */
- if ( ch == (char) 0)
- {
- printf( "0 (extended) + ");
- ch = getch( );
- } /* leading null for a pc extended char? */
- printf( "%d <- ascii code\n", (int) ch);
- #else
- printw( "\nPress any key: ");
- refresh( );
-
- /* read a char using system v "curses" routine: */
- ch = getch( );
- printw( "%d <- ascii code\n", (int) ch);
- refresh( );
- #endif
- } /* until enter/return or linefeed */
-
- #ifndef __TURBOC__
- endwin( );
- #endif
- }
-
-
- /* ****** EOF: KBTEST.C ****** */
-