Saving a global object to a global array, changing values in object and saving again
<p>Trying to capture the time between keyup and keydown as well as between keyup and the keydown of the next keystroke by writing the time and key data to a global object using keys and values and pushing this object to a global array.  The reason for globals is that I don't know how to pass parameters between functions bound to the keydown, keypress and keyup events.  Each event driven function has data I want to save in one object as key value pairs such as the key code and the character typed. Each object represents one keystroke but also contains or uses for calculation some information from the previous keystroke.</p>

<p>By the end the data in each element of the global array seems to be either undefined or the last data entered.</p>

<p>My question is why?</p>

<p>I worked around the problem by eliminating the global object(key values) and replacing it with global variables which change with each keystroke.  Then I was able to create an object in a function (function scope) and push that object in the global array with each new character. It seems to work. Instinctively it feels like it should be the other way around.  I just want to understand why it works this way.  I am a third of the way through the book by Zakas and have a lot more to learn.  </p>
