That is the sort of thing.
However the
else{
noTone(9);
Bit means it will never produce any sound because all keys are not pressed at the same time and any unpressed key will stop the sound. Just leave that part out or use it for when no key is pressed.