title: Detect whether CapsLock is on or off in Silverlight
body: <p>You may find if the CapsLock key has been pressed subscribing to the KeyDown/KeyUp event. And then toggle the state of the CapsLock based on that input. The problem with this approach is that you need the initial state of the CapsLock key to start toggling that.</p>
  
  <p>One application of this could be giving the user a notification on a Login Page (this is what i need).</p>
  
  <p>By the way i'm using Silverlight 5.</p>
  
  <h2><strong>EDIT</strong></h2>
  
  <p>The solution posted <a href="http://forums.silverlight.net/post/185708.aspx" rel="nofollow noreferrer">here</a> says:</p>
  
  <blockquote>
    <p>You can however find out if Capslock is on by making use of
    KeyEventArgs.PlatformKeyCode that's actually send at onKeyDown.You can
    look up the Virtual Key-code for capslock in here:
    <a href="http://msdn.microsoft.com/en-us/library/ms927178.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/ms927178.aspx</a></p>
  </blockquote>
  
  <p>With this solution you can't determine the CapsLock state, because <code>KeyEventArgs.PlatformKeyCode</code> returns "an integer value that represents the key that is pressed or released (depending on which event is raised)". So if CapsLock is On and Key A is pressed then <code>KeyEventArgs.PlatformKeyCode = 65</code>, and on the other hand if CapsLock is off and Key A is pressed then <code>KeyEventArgs.PlatformKeyCode = 65</code>.</p>
  
  <p>In other words you can't determine if the CapsLock is enabled or not based on the <code>KeyEventArgs.PlatformKeyCode</code> property.</p>
  
  <hr>
  
  <p>The answer to <a href="https://stackoverflow.com/q/733102/590956">this</a> question also seems to have a solution, it checks two things:</p>
  
  <ol>
  <li>the letter typed is Upper Case and Shift isn't pressed</li>
  <li>the letter typed is Lower Case and Sift is pressed</li>
  </ol>
  
  <p>Both of this cases implies that the CapsLock is On, but there is  also a problem with this solution, given a KeyEventArgs you can know the pressed key in the keyboard but can't know the Char outputted by that key.</p>