linux curses库的keypad模式

#include <unistd.h>
#include <stdlib.h>
#include <curses.h>
int main()
{
int key;

initscr();
crmode(); //
keypad(stdscr,TRUE);

noecho();
clear();
mvprintw(5,5,"key pad demonstration,press 'q' to quit");
move(7,5);
refresh();
key = getch();

while(key != ERR && key != 'q')
{
move(7,5);
clrtoeol();  //

if((key >= 'A'&&key<='Z')||(key >= 'a'&&key<='z'))
{
printw("key was %c",(char)key);
}
else
{
switch(key)
{
//case LOCAL_ESCAPE_KEY:printw("%s","escapte key");break;
case KEY_END:printw("%s","end key");break;
case KEY_BEG:printw("%s","begin key");break;
case KEY_RIGHT:printw("%s","right key");break;
default:printw("unmatched - %d",key);break;
}

refresh();
key=getch();
}

endwin();
exit(0);
}
}

你可能感兴趣的:(linux curses库的keypad模式)