基本上,我的控制台应用程序有按键检测,由于某种原因它没有检测到功能键。
这是我的代码,我在 linux 上使用 GNU 编译器。任何帮助或想法将不胜感激。
refresh();
key = getch();
switch(key) {
case KEY_HOME: key = HOME; break;
case KEY_END: key = END; break;
case KEY_UP: key = UP; break;
case KEY_DOWN: key = DOWN; break;
case KEY_LEFT: key = LEFT; break;
case KEY_RIGHT: key = RIGHT; break;
case KEY_NPAGE: key = PGDN; break;
case KEY_PPAGE: key = PGUP; break;
case KEY_DC: key = DEL; break;
case KEY_IC: key = INSERT; break;
case KEY_F(1): key = F(1); break;
case KEY_F(2): key = F(2); break;
case KEY_F(3): key = F(3); break;
case KEY_F(4): key = F(4); break;
case KEY_F(5): key = F(5); break;
case KEY_F(6): key = F(6); break;
case KEY_F(7): key = F(7); break;
case KEY_F(8): key = F(8); break;
case KEY_F(9): key = F(9); break;
case KEY_F(10): key = F(10); break;
case KEY_F(11): key = F(11); break;
case KEY_F(12): key = F(12); break;
case KEY_ENTER: key = ENTER; break;
case KEY_BACKSPACE: key = BACKSPACE; break;
default:
//key = F(2); //For any function keypress, it jumps to default
if (NON_ASCII(key) != 0)
key = UNKNOWN;
}