Grow your CSS skills. Land your dream job.

This code is not working properly in chrome browser…

  • # May 24, 2013 at 4:16 am

    $(document).keypress(function (e) {
    if( e.ctrlKey && (e.which == 17 || e.which==48) ) {

    alert(“crtl+0″);
    }

    else if (e.ctrlKey && (e.which == 17 || e.which==61) ) {

    alert(“crtl+plus”);
    }

    else if (e.ctrlKey && (e.which == 17 || e.which==43) ) {

    alert(“ctrl+plus2″);
    }

    else if (e.ctrlKey && (e.which == 17 || e.which==45) ) {

    alert(“ctrl+minus”);
    }

    });

    # May 24, 2013 at 4:45 am

    What are you trying to do? Detect browser zoom? Be aware that zoom can be changed in the menu in which case the event won’t be triggered.

    There are 3 key events: keydown, keypress and keyup. `keypress` is special because it is only triggered for keys and key combinations which can insert characters (I’m simplifying of course) and sets `e.which` to the ascii code of the pressed letter instead of the key code. I think that’s becuase it’s main use is to capture user input.

    `keyup` is probably the better option here.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".