CAPS LOCK key detect

This is a discussion on CAPS LOCK key detect within the Windows Programming forums, part of the Platform Specific Boards category; Dear All, I am working in a C programme which need to check the CAPS LOCK key state. I need ...

  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    9

    Smile CAPS LOCK key detect

    Dear All,
    I am working in a C programme which need to check the CAPS LOCK key state. I need to check weather the CAPS LOCK is on state or off. Unlike other keys, once you press CAPS LOCK key it goes to ON state and OFF when press again. I have tried this by using GetAsyncKeyState and GetKeyState functions and I cant do that usimng those functions.

    Pls help me to findout a code for this in.

  2. #2
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591
    I believe the key state of capslock is actually maintained by the keyboard rather then the system (you can see this in simple OSs such as DOS or even by hitting capslock before you finish booting). Of course, you'd still be able to detect when it was hit, and might be able to resolve a working solution from there. Still, I'd be interested in seeing the answer to this question, as I am not 100 percent sure on this.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,338
    So have you gone to MSDN, looked up say GetAsyncKeyState(), then gone exploring the related functions to see if anything seems likely?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,189
    GetKeyboardState() is the function you want.
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 11-23-2007, 12:48 PM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 09:00 AM
  3. Directional Keys - Useing in Console
    By RoD in forum C++ Programming
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM
  4. FAQ: Directional Keys - Useing in Console
    By RoD in forum FAQ Board
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21