how to identify key commands js code example

Example: js detect cmd+s

// To detect Cmd key pressed, check Event.key === 'Meta'
document.querySelectorAll('#form').forEach(form => {
	let meta_pressed = false;
	form.addEventListener('keydown', e => {
		if ( e.key === 'Meta' ) {
			meta_pressed = true;
		} else if ( e.key === 's' ) {
          	// Keep the browser from running its own
          	// Cmd+S (Save Page As...) function
			e.preventDefault();
			form.submit();
		}
	});
	form.addEventListener('keyup', e => {
		if ( e.key === 'Meta' ) {
			meta_pressed = false;
		}
	});
});