Part 2: User Input from mouse click to keyinput of "Enter/Return" key

We will use the file created in Part 1

We will now make a Key Listener for the "Enter/Return" key being substitued for the button click

Place this in the <script> section


We also need to edit the button in HTML to a paragraph without text

Change:

<button onclick="displayMessage()">Click me</button>

To this:


Now Lets have a little fun with the program

Change:

<input type="text" id="msg" ><br>

document.getElementById("showinputhere").innerHTML = themsg;}

To this:

<p>Name:<input type="text" id="msg" ></p><br>

document.getElementById("showinputhere").innerHTML = (`Hello ${themsg} is not JavaScript DOM programming fun.`);}

I hope with just this small example you can see the pontential