Example: #include #include #include #include #include #include #include #define ERROR -1 void main() { int fd; long mode; /* To be used as the fd in ioctl(). */ if ((fd = open("/dev/console", O_NOCTTY)) == ERROR) { perror("open"); exit(ERROR); } printf("w00w00!\n\n"); if ((ioctl(fd, KDGKBMODE, &mode)) == ERROR) { perror("ioctl"); close(fd); exit(ERROR); } printf("Keyboard in "); if (mode == K_RAW) printf("raw mode.\n"); else if (mode == K_XLATE) printf("xlate mode.\n"); else if (mode == K_MEDIUMRAW) printf("medium raw mode.\n"); else if (mode == K_UNICODE) printf("Unicode mode.\n"); else printf("0x0%x\n", mode); /* For future modes.\n"); close(fd); }