Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Is there a javascript event handler for the enter key?

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #238477
    delta
    Participant

    I tried using onkeydown and onkeypress but the space key seems to trigger it, so do other keys on the keyboard. Is there an event handler that will only trigger then the user persses the return/enter key?

    #238485
    bearhead
    Participant

    You have to use an if statement to test if the enter key is pressed (jquery method):

    http://codepen.io/kvana/pen/yOLBoJ

    The key code for the enter key is 13, here is a pen that will help you find the code for any key on your keyboard (not my work):
    http://codepen.io/Jackthomsonn/pen/memNpM

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.