In a Silverlight application’s log in screen, i need to determine if Caps Lock is toggled. This is easy enough by handling the KeyUp or KeyDown event, however how does one determine if it is toggled on or off even if a key hasn’t been pressed?
The reason I want todo this is what if the user doesn’t press Caps Lock while the Silverlight application is running, but rather they toggled it before they even got to the login screen? I need to still warn them that caps Lock is on.
Apparently handling unmanaged code is not possible in Silverlight so the following doesn’t work.
[DllImport(‘user32.dll’)] internal static extern short GetKeyState(int keyCode);
The way to detect CAPS LOCKS is to check the KeyValue and the Shift of KeyEventArgs.
if the KeyValue is (for example) ‘A’ but the Shift is false then the CAPS LOCKS is on.
Not the best way but its how ajax applications has been doing it.