Jeśli kod klucza zdarzenia i kliknij

function advance(event) {
  if (event instanceof MouseEvent) {
    console.log('clicked');
  } else if (event instanceof KeyboardEvent && event.keyCode === 13) {
    console.log('enter');
  }
}

window.addEventListener('keypress', advance);
Nice Nightingale