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
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post

    capture keypress

    Hi Guys,

    I'm trying to capture a keypress, and in particular looking for the cursor up and cursor down key stroke.

    I have a hyperlink (with a value of 0) and when the user clicks on it, they should be able to navigate the value up and down using the cursor keys. here's what I have so far

    Code:
    function eg3(ctrl) {
    	var current = ctrl.innerHTML;
    	var new_figure = (parseFloat(current) + 1);
    	ctrl.innerHTML = new_figure;
    }
    
    <a href="#" id="eg3_1" onKeyDown="return eg3(this)">0</a>
    it works ok in that when the user clicks it, you can press any key and it increments by one. I need to capture the cursor up and down keys though.

    any ideas?! I'm lost!!

  • #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
    You talking about mouse click?
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post
    no, i am after capturing the keypress!

    all I need to do is capture what key the user has pressed and if it's the cursor key up, increment the value by one... if it's down, then take one off the current value.

    I get the keypress, but I cannot seem to find out which key they've pressed!


  •  

    Posting Permissions

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