Thread: CAPS LOCK key detect

  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 int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    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.

  4. #4
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    GetKeyboardState() is the function you want.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 11-23-2007, 01:48 PM
  2. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10: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