This code snippet below will show you how to detect the pressing of keyboard enter key using JavaScript.

document.addEventListener( 'keydown', function( ev ) {
	var keyCode = ev.keyCode || ev.which;
	
	if( keyCode === 13 ) {
		ev.preventDefault();
		
		alert('Enter Key Pressed');
	}
});

Try it yourself →