Home
> Silverlight 5 > Finding Key State using PInvoke in SL5 RC
Finding Key State using PInvoke in SL5 RC
If we have to find the Key State of CAPS lock, NUM lock etc in silverlight 5 RC, we could do like this using PInvoke
Add the Declaration
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
public static extern short GetKeyState(int keyCode);
And to get the different Key states
bool CapsLock = (((ushort)GetKeyState(0×14)) & 0xffff) != 0;
bool NumLock = (((ushort)GetKeyState(0×90)) & 0xffff) != 0;
bool ScrollLock = (((ushort)GetKeyState(0×91)) & 0xffff) != 0;
Categories: Silverlight 5
Comments (0)
Trackbacks (1)
Leave a comment
Trackback
-
September 26, 2011 at 4:46 am | #1Windows Client Developer Roundup 082 for 9/26/2011 (Giant Post-Build Edition) – Pete Brown’s 10rem.net