How to get Ctrl, Shift or Alt with getch() ncurses?

后端 未结 7 1438
挽巷
挽巷 2020-12-10 03:11

How to get Ctrl, Shift or Alt with getch() ncurses ?
I cannot get it work to get Ctrl, Shift or

7条回答
  •  温柔的废话
    2020-12-10 03:33

    You can call key_name( c ) to turn the key generated from getch() into something that shows you the state of the ctrl-modifier.

    For example this code shows "^R" if you press ctrl-r:

    while( true )
    {
       char c = getch();
       if ( ERR == c )
          break;
    
       const char *name = key_name( c );
    
       move( 2, 2 );
       clear();
       printw( "You entered: %s             ", name );
       refresh();
    
    }
    

提交回复
热议问题