二 可以用这个软件锻炼自己的打字说平,每按下一个键盘上面的字符。屏幕上就会显示该字符。
代码://该程序用于锻炼键盘打字水平
#include <unistd.h>
#include <stdlib.h>
#include <curses.h>
#define LOCAL_ESCAPE_KEY 27
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 if((key>='0'&&key<='9')){
printw("key was %c",(char)key);
}
else
{
switch(key){
case LOCAL_ESCAPE_KEY:printw("%s","Escape key");break;
case KEY_END:printw("%s","END_KEY");break;
case KEY_BEG:printw("%s","BEG_KEY");break;
case KEY_RIGHT:printw("%s","RIGHT_KEY");break;
case KEY_LEFT:printw("%s","LEFT_KEY");break;
case KEY_UP:printw("%s","UP_KEY");break;
case KEY_DOWN:printw("%s","DOWN_KEY");break;
case 9:printw("%s","Tab key");break;
case 13:printw("%s","Enter key");break;
case 20:printw("%s","Caps Lock");break;
case 10:printw("%s","ENTER");break;
case 17:printw("%s","ctrl");break;
case 18:printw("%s","Alt");break;
case 32:printw("%s","VK_SPACE");break;
case 8:printw("%s","back");break;
case 91:printw("%s","[");break;
case 92:printw("%s","|);break;
case 93:printw("%s","]");break;
case 96:printw("%s","~");break;
case 45:printw("%s","-");break;
case 262:printw("%s","Home");break;
case 263:printw("%s","Backspace");break;
case 331:printw("%s","insert");break;
case 339:printw("%s","Page Up");break;
case 338:printw("%s","Page down");break;
case 330:printw("%s","Delete");break;
case 39:printw("%s"," feihao ");break;
case 61:printw("%s"," = ");break;
case 59:printw("%s",":");break;
case 44:printw("%s","<");break;
case 46:printw("%s",">");break;
case 47:printw("%s","?");break;
default:printw("Unmatched-%d",key);break;
}
}
refresh();
key=getch();
}
endwin();
exit(EXIT_SUCCESS);
}