Segue o código, caso encontre alguma problema me avisem, por favor.
function tocaSom (idElementoAudio) {
    document.querySelector(idElementoAudio).play();
}
const listaDeTeclas = document.querySelectorAll('.tecla')
for (let i = 0; i < listaDeTeclas.length; i++) {
    const teclas = listaDeTeclas[i]
    const instrumento =  teclas.classList[1]
    const som = ("#som_"+instrumento)
    teclas.onclick = function () {
        tocaSom(som)
    }
    teclas.onkeydown = function (evento) {
        if(evento.code==='Enter' || evento.code==='Space'){
            teclas.classList.add('ativa');
        }
    }
    teclas.onkeyup  = function () {
        teclas.classList.remove('ativa');
    }
} 
            