SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question [SOLVED] Find keypress in form

    I want to trigger something when a user presses a key in a form.
    I've tried this, but it's not working:
    <form onKeyPress="key = event.keycode ? event.keycode : keypress.which; alert(key);">

    Any suggestions to "where" I can find the "key"?
    Last edited by ZoRaC; Aug 19, 2008 at 23:41.

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Have a good read of this page here.
    http://www.quirksmode.org/js/keys.html
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Member
    Join Date
    Aug 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Solution:
    onKeyPress="key = event.keyCode ? event.keyCode : event.which; alert(key);">


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •