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 to the CF scene
    Join Date
    Jul 2002
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Internet Explorer keyCode for crtl+enter

    I'm trying to call a function from a specific keyCode entry using "onKeypress".

    now, the function i'm calling to, needs to be able to recognize "ctrl+enter". What I have so far is this:


    -------------------------------------------------------------------

    var reValidChars = /\d/;
    var reKeyboardChars = /[\x08\x0D]/;

    function ctrl_Enter(objEvent) {
    var iKeyCode, strKey;
    if (objEvent.keycode == "10") {
    if (!reValidChars.test(strKey) && !reKeyboardChars.test(strKey)) {
    window.alert('you hit ctrl plus enter!');
    }
    }
    }

    ------------------------------------------------------------------

    Any input will help!! I have been lothing over my computer screen for days now.

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,950
    Thanks
    0
    Thanked 236 Times in 233 Posts
    use onkeydown instead of onkeypress.

    var ctrl = event.ctrlKey;
    var code = event.keyCode;

    alert(ctr);
    alert(code);

    if (ctrl && code==13)
    alert("You press CTRL+Enter");

    I'm not sure that the keyCode for Enter is 13 (or 10?), change it appropriately if it was wrong. I did not test it.

  • #3
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thanks! Much less code, It works great as-is.



  •  

    Posting Permissions

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