You're on the right track in storing the clicks in an array. As far as rhythm and timing, when the user wants to start "recording" you can start a timer, I'd every 200ms or so. You can use that timer to determine at what point in time the key was clicked for use when playing it back.
I don't know if something like a long press is something you'd need, but to do that, with the same timer, you can set a start time and end time (press-->release) and just subtract the end time from the start time and now you have the duration of how long the key was pressed
EDIT: here is a quick example of what I was referring to in my original post: http://ronnieswietek.com/piano/piano_example.swf
the source: http://ronnieswietek.com/piano/piano_example.fla