Programmatically press "Left" key in a text input
e = jQuery.Event("keydown"); // define this once in global scope
e.which = 37; // Some key value
$("input").trigger(e);
where "input" is your textarea
37 - left
38 - up
39 - right
40 - down
So when you record your "events" you record the values for the keys pressed.
I'm sure you already figured out a way to do this but just in case, here's an idea of how i would tackle it:
var keysPressed = new Array(); // somewhere in the global scope
$("input").keydown(function (e) {
keysPressed.push(e.which); //adding values to the end of array
});
Hope this helps
And for those not viewing jQuery as the solution to everything :)
From http://blog.josh420.com/archives/2007/10/setting-cursor-position-in-a-textbox-or-textarea-with-javascript.aspx
function setCaretPosition(elemId, caretPos) {
var elem = document.getElementById(elemId);
if(elem != null) {
if(elem.createTextRange) {
var range = elem.createTextRange();
range.move('character', caretPos);
range.select();
}
else {
if(elem.selectionStart) {
elem.focus();
elem.setSelectionRange(caretPos, caretPos);
}
else
elem.focus();
}
}
}