Ben Ben - 10 months ago 44
HTML Question

How to trigger HTML button when you press Enter in textbox?

So the code that I have so far is:

<fieldset id="LinkList">
<input type="text" id="addLinks" name="addLinks" value="http://">
<input type="button" id="linkadd" name="linkadd" value="add">

It is not in a
and is just as it is within a
. However when I type something into the
called "addLinks" I want the user to be able to press Enter and trigger the "linkadd"
which will then run a JavaScript function.

How can I do this?


I did find this code, but it doesnt seem to work.

if(event.keyCode == 13){

Answer Source