📄 getch.c
字号:
#include <stdlib.h>#include <stdio.h>#include <unistd.h>#include <termios.h>#include <fcntl.h>int getch(void){ struct termios tm, tm_old; int fd = STDIN_FILENO; char c; if(tcgetattr(fd, &tm) < 0) printf("error!\n"); if(tcgetattr(fd, &tm_old) < 0) printf("error!\n"); cfmakeraw(&tm); if(tcsetattr(fd, TCSANOW, &tm) < 0) printf("error!\n"); c = fgetc(stdin); if(tcsetattr(fd, TCSANOW, &tm_old) < 0) printf("error!\n"); if(c == 0x38 || c == 0x32) { if(c == 0x38) { return -2; } else { return -1; } } else { return c; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -