The KeyState control indicates to the user the state of various toggle keys, such as the Caps Lock key, the Num Lock key, and others. We add a KeyState control like this:
<HTML>
<HEAD>
<TITLE>OCX Control Page</TITLE>
</HEAD>
<BODY LANGUAGE = VBScript ONLOAD = "Page_Initialize">
<CENTER>
<H1>OCX Control Page</H1>
</CENTER>
.
.
.
<!- Keystate>
<PRE>
--> KeyState: <OBJECT CLASSID="clsid:B9D22270-0C24-101B-AEBD-04021C009402"
HEIGHT=50 WIDTH=50 ID=Keystate1></OBJECT>
</PRE>
.
.
.
</SCRIPT>
</BODY>
</HTML>
We select the toggle key to watch by setting the Style property this way:
Style Key State
----- ---------
0 CapsLock
1 NumLock
2 Insert key
3 ScrollLock
The default Style is 0, which means the KeyState control displays the state of the Caps Lock key, as shown in Figure 6.4. This control is useful if your code depends on the state of the various toggle keys, because the control displays the state of those keys automatically for the user. Although KeyState checks the state of the keyboard regularly, you can make certain that its appearance is up-to-date at any time by calling its Refresh method. Now let's move on to another powerful control: the rich text control.