VBScript Timer Function - Touch Type Speedometer

The touch typing tester uses the timer() function to calculate the time taken to type the sentence. The only problem with this occurs if the test is started before midnight and completed after midnight. Notice that we have included a line in the script that checks for this and adds 86400 seconds to the result if midnight has passed.

<SCRIPT language="vbscript">
<!--
dim x, y, z
z = 0
sub document_onkeypress()
if z = 0 then
z = 1
x = timer()
bdy.innerHTML = bdy.innerHTML & chr(window.event.keycode)
else
if window.event.keycode <> 13 then
bdy.innerHTML = bdy.innerHTML & chr(window.event.keycode)
else
bdy.innerHTML = bdy.innerHTML & "<br>"
y = timer()
if bdy.innertext = test.innertext then
if y < x then
y = y + 86400
end if
timetaken = y - x
stringlength = len(test.innertext)
speed= stringlength/timetaken
msgbox "It took you " & timetaken & " seconds to type that sentence" & chr(13) &_
"Your speed was " & speed & " Characters per Second"
else
msgbox "You made a mistake ... try again"
bdy.innertext = ""
Z = 0
end if
end if
end if
end sub
-->
</SCRIPT>

Within the body of the page you will need to add a paragraph with the id "test" and a div with the id "bdy". The paragraph is the sentence to be typed (and compared). The div provides a place to type the sentence.

<p id="test">She sells sea shells on the sea shore.</p>

<div id="bdy"></div>


Touch Type Tester

Requires Internet Explorer (4 or greater). Other browsers do not support VBScript

Type the following paragraph then press enter:

She sells sea shells on the sea shore.



Kathie Kingsley-Hughes
Last updated: May 4th 2004
Print This Page   |   Email me when this page changes    |  Search This Site



Crucial.com System Scanner does the work for you!



/a_global/close_links.inc"); ?>

Contact Us