Each piano key has unique frequency. So the frequency domain i.e fourier transformation helps to identify the pattern of the pure sound from noise. That pattern you could use compare the sound.
"Another thought I had was that a note should be more or less the same each time it is played. If that is the case could a percentage match on two wav files turned into byte arrays be of any use?"
This idea works only for one piano with constant setting. For example if the volume of the piano increase/ decrease which again depends on the distance of the recorder device then the byte array will not be comparable every time. Then you need to normalize the data for various such parameters.
Instead frequency will remain same. Well other things like pitch, timbre also important parameters.
Dylan Morley given a link about pitch detection. You may get more information from other people as well.
Here is a link for a free library which has functionality to transform audio to fourier and Hilbert transforms
http://accord-net.origo.ethz.ch/wiki/features[
^]
Good luck