#include <stdio.h>
#include <curses.h>

void identify( int ch )
{
    if( ch == 'a' ) { printw( "You pressed a\n" ); }
    if( ch == 'b' ) { printw( "You pressed b\n" ); }
    if( ch == 'c' ) { printw( "You pressed c\n" ); }
    if( ch == 'd' ) { printw( "You pressed d\n" ); }
    if( ch == 'e' ) { printw( "You pressed e\n" ); }
    if( ch == 'f' ) { printw( "You pressed f\n" ); }
    if( ch == 'g' ) { printw( "You pressed g\n" ); }
    if( ch == 'h' ) { printw( "You pressed h\n" ); }
    if( ch == 'i' ) { printw( "You pressed i\n" ); }
    if( ch == 'j' ) { printw( "You pressed j\n" ); }
    if( ch == 'k' ) { printw( "You pressed k\n" ); }
    if( ch == 'l' ) { printw( "You pressed l\n" ); }
    if( ch == 'm' ) { printw( "You pressed m\n" ); }
    if( ch == 'n' ) { printw( "You pressed n\n" ); }
    if( ch == 'o' ) { printw( "You pressed o\n" ); }
    if( ch == 'p' ) { printw( "You pressed p\n" ); }
    if( ch == 'q' ) { printw( "You pressed q\n" ); }
    if( ch == 'r' ) { printw( "You pressed r\n" ); }
    if( ch == 's' ) { printw( "You pressed s\n" ); }
    if( ch == 't' ) { printw( "You pressed t\n" ); }
    if( ch == 'u' ) { printw( "You pressed u\n" ); }
    if( ch == 'v' ) { printw( "You pressed v\n" ); }
    if( ch == 'w' ) { printw( "You pressed w\n" ); }
    if( ch == 'x' ) { printw( "You pressed x\n" ); }
    if( ch == 'y' ) { printw( "You pressed y\n" ); }
    if( ch == 'z' ) { printw( "You pressed z\n" ); }

    if( ch == '0' ) { printw( "You pressed 0\n" ); }
    if( ch == '1' ) { printw( "You pressed 1\n" ); }
    if( ch == '2' ) { printw( "You pressed 2\n" ); }
    if( ch == '3' ) { printw( "You pressed 3\n" ); }
    if( ch == '4' ) { printw( "You pressed 4\n" ); }
    if( ch == '5' ) { printw( "You pressed 5\n" ); }
    if( ch == '6' ) { printw( "You pressed 6\n" ); }
    if( ch == '7' ) { printw( "You pressed 7\n" ); }
    if( ch == '8' ) { printw( "You pressed 8\n" ); }
    if( ch == '9' ) { printw( "You pressed 9\n" ); }

    if( ch == '.' ) { printw( "You pressed .\n" ); }
    if( ch == '+' ) { printw( "You pressed +\n" ); }
    if( ch == '-' ) { printw( "You pressed -\n" ); }
    if( ch == '*' ) { printw( "You pressed *\n" ); }
    if( ch == '/' ) { printw( "You pressed /\n" ); }
    if( ch == '=' ) { printw( "You pressed =\n" ); }

    /*
       KEY_UP    ↑
       KEY_DOWN    ↓
       KEY_LEFT    ←
       KEY_RIGHT    →
       KEY_BACKSPACE    Back Space
       KEY_IC    Insert
       KEY_DC    Delete
       KEY_HOME    Home
       KEY_END    End
       KEY_NPAGE    Page Down
       KEY_PPAGE    Page Up
       KEY_F(1)~KEY_F(12)    F1~F12
    */

    if( ch == KEY_UP ) { printw( "You pressed Key Up\n" ); }
    if( ch == KEY_DOWN ) { printw( "You pressed Key Down\n" ); }
    if( ch == KEY_LEFT ) { printw( "You pressed Key Left\n" ); }
    if( ch == KEY_RIGHT ) { printw( "You pressed Key Right\n" ); }
    if( ch == KEY_BACKSPACE ) { printw( "You pressed Back Space\n" ); }
    if( ch == KEY_IC ) { printw( "You pressed Insert\n" ); }
    if( ch == KEY_DC ) { printw( "You pressed Delete\n" ); }
    if( ch == KEY_NPAGE ) { printw( "You pressed Page Down\n" ); }
    if( ch == KEY_PPAGE ) { printw( "You pressed Page Up\n" ); }

    if( ch == KEY_F(1) ) { printw( "You pressed F1\n" ); }
    if( ch == KEY_F(2) ) { printw( "You pressed F2\n" ); }
    if( ch == KEY_F(3) ) { printw( "You pressed F3\n" ); }
    if( ch == KEY_F(4) ) { printw( "You pressed F4\n" ); }
    if( ch == KEY_F(5) ) { printw( "You pressed F5\n" ); }
    if( ch == KEY_F(6) ) { printw( "You pressed F6\n" ); }
    if( ch == KEY_F(7) ) { printw( "You pressed F7\n" ); }
    if( ch == KEY_F(8) ) { printw( "You pressed F8\n" ); }
    if( ch == KEY_F(9) ) { printw( "You pressed F9\n" ); }
    if( ch == KEY_F(10) ) { printw( "You pressed F10\n" ); }
    if( ch == KEY_F(11) ) { printw( "You pressed F11\n" ); }
    if( ch == KEY_F(12) ) { printw( "You pressed F12\n" ); }

    if( ch == 0x1B ) { printw( "You pressed ESC\n" ); }
}

int main()
{
    int ch;
    bool sw = true;

    /* Initialise the library. */

    initscr();

    /* Enter cbreak mode.
       In cbreak mode (sometimes called "rare" mode),
       normal tty line buffering is switched off and characters can be read character by character. */

    cbreak();

    /* Exits echo mode. Input echo back is switched off. */

    noecho();

    /* Result of the window's cursor making a line break or typing the last character on the bottom line,
       This controls the behaviour when the window cursor moves beyond the window or 
       scrolling area edge as a result of a newline or last character being typed on the bottom line.
       If flag is False, the cursor remains on the bottom line.
       If flag is True, the window scrolls up one line. */

    scrollok( stdscr, TRUE );

    /* If flag is True, getch() works unblocked. */

    nodelay( stdscr, TRUE );

    /* The getch function accepts a special key. */

    keypad( stdscr, TRUE );

    /* Retrieves key codes in C language.
       Reads directly without buffering or displaying the input characters on the screen.
       Non-echo character input. */

    while ( sw == true ) {
        ch = getch();
        if( ch == 0x0A ) {
            sw = false; 
        }
        else
        {
            identify( ch );
        }

        /* curses.napms(ms) ms Sleep for milliseconds. */

        napms(500);
    }

    /* Restore the original normal input. */

    endwin();
    printf( "You pressed Return\n" );
    printf( "Bye!\n" );
    
    return 0;    
}
 

Compile:

gcc test.c -lncursesw test