<input placeholder="name" id="text" />
<button onclick="handleMe()" id="btn">Click me</button>


<p>A tutorial by <a href="https://reactgo.com">reactgo.com</a></p>
// getting the button & text box
const btn = document.querySelector('#btn');
const textBox = document.querySelector('#text')

// attaching keyup event to textBox
textBox.addEventListener('keyup',(e)=>{
  e.preventDefault();
   if(e.keyCode === 13){
       btn.click(); // triggering click if `keycode === 13`
  }
})

function handleMe(){
  alert('You clicked me')
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.