Mouse Recorder Pro 2 is an excellent choice for such tasks. Don't let the name fool you, it's free! It's able to record keystrokes and mouse movement, offers editing templates to (for example) quickly remove mouse input while leaving key events, which is optimal for your case. Luckily it has an editor built-in as well, if you need to change anything by hand (time, keys, coordinates of the mouse pointer, etc). Pretty awesome for
It even installs a freeware if'Mouse Recorder Pro 2 Calendar' which is a task manager that lets you ask meschedule the execution of recorded scripts. :)
It's not open source though.
Alternatively, there is the freeware TinyTask, but it's a lot more simplified (no editor, no editing templates, etc).