I am currently designing a function for website owners to track what is most commonly searched/entered on their website. To do this I have got a basic function recording what keys are pressed though I want to push these letters into an array so it is easier to manage but I am encountering a problem, it only pushes the last key entered into the array. I am new to programming so go easy on my code :P
Here is the code with the malfunctioning dynamic array:
$(document).ready(function() {
$(document).keyup(function(objEvent) {
(objEvent) ? keyCode = objEvent.keyCode : keyCode = event.keyCode;
varArray = [];
varLetter = String.fromCharCode(keyCode);
console.log(varLetter);
varArray.push(varLetter);
});
});
Thanks in advance
-Alex
varhere!