I have a function which counts key strokes and I need to be able to access the values which it returns for further processing.
At the moment, the function itself works and the variable is correctly displayed in an alert box, but I don't seem to be able to assign that value to another var.
It seems I am missing something crucial here:
I have tried adding a return statement inside the function- not needed, and didn't help.
I tried declaring new variables inside the function and giving them the value totalKeyStrokes, with the result 'undefined'.
The array which I have just seems to be able to access the original value of totalKeySrokes (ie 0).
Is there anyone who can give me a clue?
This is an intermediate step which is holding me up....
here is the offending section of code:
/*counting key presses*/
var totalKeyStrokes = 0;
function CountKeyStrokes() {
if (foo % 2 == 0) {
totalKeyStrokes = ++totalKeyStrokes;
/*onkeyup used instead of onkeydown, to prevent multiple entries in windows if held down*/
document.onkeyup = CountKeyStrokes;
var incrementTotal = new Array(3);
incrementTotal[0] = totalKeyStrokes;
incrementTotal[1] = totalKeyStrokes;
incrementTotal[2] = totalKeyStrokes;
var incrementSet = (incrementTotal[0]+" "+incrementTotal[1]+" "+incrementTotal[2]);