Find the answer to your Linux question:
Results 1 to 3 of 3
Does anyone know how to turn the caps lock, num lock & scroll lock LED in keyborad on and off in C or Python. Thanks...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2004
    Posts
    2

    caps lock, num lock & scroll lock


    Does anyone know how to turn the caps lock, num lock & scroll lock LED in keyborad on and off in C or Python. Thanks

  2. #2
    Linux Engineer
    Join Date
    Sep 2003
    Location
    Knoxhell, TN
    Posts
    1,078
    you have to send a scancode to the keyboard.. i'm not sure exactly which one is sent, but there are a few resources on the web about scancodes...

    once you find the scancode, you should be able to just do something like this:

    Code:
    FILE *openkbd(char *file)
    {
          FILE *fp=NULL;
    
          fp=fopen(file,"w+");
          return (fp)
    }
    
    int main()
    {
           char *file=NULL;
           FILE *fp=NULL;
    
           file=malloc(fsizeof(char)*256);
           scanf("%s",file);
           fp=openkbd(file);
    
           write&#40;fp, "<scancode goes here>"&#41;;
    
           return 0;
    &#125;
    that's just a rough example and some of my syntax may be off.. i'm a bit tired atm.... but the idea is to open the /dev file for the keyboard and write the scancode to it.
    Their code will be beautiful, even if their desks are buried in 3 feet of crap. - esr

  3. #3
    Linux Guru
    Join Date
    Mar 2003
    Location
    Wisconsin
    Posts
    1,907
    Here is a link some code that blinks the keyboard LEDs. It might help or give you a start. From here there's also a link to a program called tled on freshmeat

    http://www.linuxgazette.com/node/view/9074

    Good Luck!
    Jeremy
    Registered Linux user #346571
    "All The Dude ever wanted was his rug back" - The Dude

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •