All Posts by Email, Once a Week

Media Temple logo

CSS-Tricks is brought to you in part by Media Temple, the web hosting that we both use and recommend.

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) ) {


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


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


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



    # 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.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed