Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hi friends,

Please help me to write code that raise alert message when CapsLock is ON in the Keyboard.


Thanks
Siva
Posted
Comments
dimpledevani 1-Mar-12 1:43am    
well there is an ASCII value for each key, serach the ASCII value n on key press event match it

This is windows, so there are at least two ways, Control.IsKeyLocked[^] and Console.CapsLock[^]
C#
if (Control.IsKeyLocked(Keys.CapsLock))
    {
    Console.WriteLine("The Caps Lock key is ON.");
    }
else
    {
    Console.WriteLine("The Caps Lock key is OFF.");
    }

And
C#
if (Console.CapsLock)
    {
    Console.WriteLine("The Caps Lock key is ON.");
    }
else
    {
    Console.WriteLine("The Caps Lock key is OFF.");
    }
 
Share this answer
 
Comments
Karthik_Mahalingam 6-Jan-14 5:33am    
good
For Windows Forms, have a look at the Control.IsKeyLocked method[^].
 
Share this answer
 
Comments
Karthik_Mahalingam 6-Jan-14 5:33am    
good
when i focused a button ,it always return false.
 
Share this answer
 

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