Click here to Skip to main content
14,735,317 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[^]
if (Control.IsKeyLocked(Keys.CapsLock))
    {
    Console.WriteLine("The Caps Lock key is ON.");
    }
else
    {
    Console.WriteLine("The Caps Lock key is OFF.");
    }

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

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

  Print Answers RSS
Top Experts
Last 24hrsThis month



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