Jika kode keycode acara dan klik

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