Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2009
    Location
    Birmingham, England
    Posts
    58
    Thanks
    5
    Thanked 5 Times in 5 Posts

    event handlers within function

    Hi,

    Basically I'm creating an auto suggest search bar, and I want to use the onKeyPress to call a function which would then detect whether the key was keyUp or keyDown and do a different function depending on where the key was.

    Is this possible?

    Any help would be great!

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    Than you should use onkeyup or onkeydown

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,343
    Thanks
    11
    Thanked 589 Times in 570 Posts
    press won't fire until the key goes up, but there is not a way (afaik) to detect the state of a key beyond the 3 standard key events.

    Also beware that holding a key in some browsers will repeat the keypress (using the OS/BIOS repeat rate), while some just fire once per press, regardless of duration.
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%


  •  

    Posting Permissions

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