How to get and set the state of "NumLock"?

I try writting some scripts to implement it but failed. Does "UnityEngine" supply any function for this?

thanks first.

There is integrity codes used "GetKeyState""GetKeyboardState" and "keybd_event" to implement the get and set of the num lock state.(in c#)

I hope it may useful for some one :)

using UnityEngine;
using System.Collections;
using System.Runtime.InteropServices;

public class SpecialKeyController {

[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
private static extern short GetKeyState(int keyCode);

private static extern int GetKeyboardState(byte [] lpKeyState);

[DllImport("user32.dll", EntryPoint = "keybd_event")]
private static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, int dwExtraInfo);

private const byte VK_NUMLOCK = 0x90; 
private const uint KEYEVENTF_EXTENDEDKEY = 1; 
private const int KEYEVENTF_KEYUP = 0x2;
private const int KEYEVENTF_KEYDOWN = 0x0;

public bool GetNumLock()
    return (((ushort)GetKeyState(0x90)) & 0xffff) != 0;

public void SetNumLock( bool bState )
    if (GetNumLock() != bState)

There is an easier way - if you're willing to track the state yourself, and don't care whether it was initially pressed. This (C#) code will read numlock:

//public var isNumLocked : boolean = false; // Javascript version.
public bool isNumLocked = false;

// function OnGUI() { // Javascript version.
void OnGUI() {
    if ((Event.current.type == EventType.KeyUp) && 
        (Event.current.keyCode == KeyCode.Numlock)) 
        isNumLocked = !isNumLocked;
        Debug.Log("numlock toggled");

Now, if you absolutely have to know whether numlock was already set by the user, then Mike is right, you need to call the Win32API to read its value. But if all you want is a toggle button, this will work fine.