slandau slandau - 1 year ago 163
HTML Question

Bind enter key to specific button on page

<input type="button" id="save_post" class="button" value="Post" style="cursor:pointer;"/>

How can I bind the enter key on the persons keyboard to this specific button on the page? It's not in a form, and nor do I want it to be.


Answer Source

This will click the button regardless of where the "Enter" happens on the page:

    if (e.which == 13){
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download