document.getElementsByClassName('class-inputa')[0].onkeypress = function(e) { if(e.key=='Enter') alert('Enter') }