How would you correctly write the sentence? I’d it correct to say « hear her nails »? One can hear a voice but can you hear nails?

You could hear her long nails clicking on/against the keyboard as she typed up a letter.

Is it also correct to hear someone cooking?

I could hear hear her cooking in the kitchen.



You'd typically try to graphically connect the sound that you hear, with what the person is doing, for example:

I could hear her long fingernails clacking on the computer keyboard as she typed a letter.

I could hear her in the kitchen; she must have been cooking up something.

They are both fine. I would write "on the keyboard", but "against" is not wrong.