Example: This will turn off the Caps Lock LED and turn Caps Lock on. The reason we are turning the LED off is just to prove a point that just because the LED isn't on doesn't mean the flag isn't. This should show you how KDSKBLED differs from KDSETLED. This DOES NOT set the keyboard LED for Caps Lock on, this actually sets Caps Lock on. To set the LED as well use KDSETLED. #include #include #include #include #include #include #include #include #define ERROR -1 void main() { int fd; int flag = 0x4; /* To be used as the fd in ioctl(). */ if ((fd = open("/dev/console", O_NOCTTY)) == ERROR) { perror("open"); exit(ERROR); } printf("w00w00!\n\n"); /* Turn off the Caps Lock LED just to show the difference */ /* between KDSETLED and KDSKBLED. */ if ((ioctl(fd, KDSETLED, 0x0)) == ERROR) { perror("ioctl"); close(fd); exit(ERROR); } /* This turns Caps Lock itself, not the light. */ if ((ioctl(fd, KDSKBLED, flag)) == ERROR) { perror("ioctl"); close(fd); exit(ERROR); } printf("To show that Caps Lock is on even though the Caps" "Lock LED isn't...\n"); printf("Enter something: "); scanf("%s", NULL); /* Turn off any LEDs on (such as Numeric Lock) since we are */ /* turning them all off with KDSKBLED right after this. */ if ((ioctl(fd, KDSETLED, 0x0)) == ERROR) { perror("ioctl"); close(fd); exit(ERROR); } /* Now the Caps Lock is off. */ if ((ioctl(fd, KDSKBLED, 0x0)) == ERROR) { perror("ioctl"); close(fd); exit(ERROR); } close(fd); }