Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I am developing a typing tutor....
In this project a want to determine that "capsLock" is on .....
please help me..
Posted

It's in the .NET API:

C#
bool isCapsLockOn = Control.IsKeyLocked(Keys.CapsLock);


Details on MSDN: Control.IsKeyLocked Method [^].

Regards,

Manfred
 
Share this answer
 
v2
Comments
Zoltán Zörgő 5-Jun-12 10:20am    
Yapp, this is how it should be! +5
Manfred Rudolf Bihy 5-Jun-12 10:31am    
Thanks Zoltán!
thatraja 5-Jun-12 15:49pm    
5!
How are you Man?
Manfred Rudolf Bihy 5-Jun-12 16:12pm    
Hi Raja!
I'm fine. How about you, how are things going for you? I haven't heard from you in a long time. :)

Greetings from Germany!
thatraja 5-Jun-12 20:22pm    
Fine, Was busy with some personal things so couldn't be active here for last 3 months. Hope you're doing fine.
 
Share this answer
 
Comments
thatraja 5-Jun-12 15:50pm    
5!
C#
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;

public class CapsLockControl
{
    [DllImport("user32.dll")]
        static extern void keybd_event(byte bVk, byte bScan, uint dwFlags,UIntPtr dwExtraInfo);
    const int KEYEVENTF_EXTENDEDKEY = 0x1;
    const int KEYEVENTF_KEYUP = 0x2;

    public static void Main()
    {
        if (Control.IsKeyLocked(Keys.CapsLock))
        {
            Console.WriteLine("Caps Lock key is ON.  We'll turn it off");
            keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr) 0);
            keybd_event(0x14, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
                (UIntPtr) 0);
        }
        else
        {
            Console.WriteLine("Caps Lock key is OFF");
        }
    }
}


or look here[^]

This solution was found here: http://cboard.cprogramming.com/csharp-programming/105103-how-detect-capslock-csharp.html[^].
 
Share this answer
 
v3
Comments
Manfred Rudolf Bihy 5-Jun-12 10:15am    
Reason for my vote of one:
This is a blatant rip of from this site: http://cboard.cprogramming.com/csharp-programming/105103-how-detect-capslock-csharp.html.
Next time you copy code from a website please add a reference to your solution that credits the originator.

Thank you!
Manfred Rudolf Bihy 5-Jun-12 13:12pm    
I added the link to the originator, since you couldn't be buggered to do so! ;)

Changed my vote too! :) 5+

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900