I am writing code for a simple web application that tells your word per minute while typing. It is set up in a table and there is a button to click when you finish. This works though it wastes some time which in turn effects the result. I am trying to come up with a way to call the same function when hitting enter as it would when you press the button.
Here is my function.
function finishTest() {
finish = new Date();
endType = finish.getTime();
totalTime = ((endType - startType) / 1000);
speed = Math.round((word/totalTime) * 60);
var totalTime1 = totalTime.toFixed(2);
if (document.form.typed.value == document.form.textArea.value) {
document.getElementById("correct").innerHTML = "You were able to type a " + word + " word sentence in "
+ totalTime1 + " seconds, a speed of roughly " + speed + " words per minute!";
}
}
Here is the table where I want the function to be called by hitting enter.
<tr>
<td colspan=2>
<center>
<input id = "typed" type=text name="typed" size=45>
<input type=button value="FINISH!" name="finish"onClick="finishTest()">
</center>
</td>
</tr>